[Pharo-project] can someone explain me this method?

Frank Shearar frank.shearar at gmail.com
Fri Jul 13 12:08:47 EDT 2012


http://www.hermetic.ch/cal_stud/jdn.htm <-- "9. Conversion Algorithms"
describes the algorithm, if not the magic numbers.

frank

On 13 July 2012 16:53, Camillo Bruni <camillobruni at gmail.com> wrote:
> comments? decent variable names? no magic numbers?
> NOW you can find NONE of that in dayMonthYearDo!
>
>
> ==================================================================
> dayMonthYearDo: aBlock
>         "Evaluation the block with three arguments: day month, year."
>
>         | l n i j dd mm yyyy |
>         l := jdn + 68569.
>         n := 4 * l // 146097.
>         l := l - (146097 * n + 3 // 4).
>         i := 4000 * (l + 1) // 1461001.
>         l := l - (1461 * i // 4) + 31.
>         j := 80 * l // 2447.
>         dd := l - (2447 * j // 80).
>         l := j // 11.
>         mm := j + 2 - (12 * l).
>         yyyy := 100 * (n - 49) + i + l.
>
>         ^ aBlock
>                 value: dd
>                 value: mm
>                 value: yyyy.
>
> ==================================================================
>
> so can anyone explain me the magic numbers here??
>




More information about the Pharo-dev mailing list