[squeak-dev] Chronology and birthdays/ages

Ken Causey klcausey at gmail.com
Fri Jun 25 22:04:47 UTC 2021


Yes, the alternative is to get years as a float or fraction and truncate,
but I think that would be a more costly calculation unless there is some
trick to calculating the number of leap years between 2 years.

On Fri, Jun 25, 2021 at 4:59 PM tim Rowledge <tim at rowledge.org> wrote:

> Yeah, it's 'interesting' like all date related stuff. Leap years add some
> extra joy.
>
> > On 2021-06-25, at 2:42 PM, Ken Causey <klcausey at gmail.com> wrote:
> >
> > This is the best I have managed, at least as a single line
> >
> > Date current year - (Date year: 1971 month: 1 day: 5) year - ((Date
> year: 1971 month: 1 day: 5) dayOfYear < Date current dayOfYear ifTrue: 0
> ifFalse: 1)
> >
> > This also works in Cuis.  Use of a variable for the birth date helps to
> reduce repetition of course.
> >
> > Ken
> >
> > On Fri, Jun 25, 2021 at 2:30 PM tim Rowledge <tim at rowledge.org> wrote:
> > I was just looking at calculating an age from birth date and 'test' date
> and was startled to find no convenient method in the relevant classes.
> Given how many things Chronology does I'm convinced I must have missed
> sometihng obvious - but where?
> >
> > tim
> > --
> > tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> > Strange OpCodes: LD: Lose Device
> >
> >
> >
> >
>
>
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> "Bother" said Pooh as he said f**k in the wrong conf.
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210625/00880341/attachment.html>


More information about the Squeak-dev mailing list