<p>I personally think that the initial confusion comes from the fact that we name a GregorianDate as Date. Once that is made explicit there is no surprise in writing:<br>
GregorianDate julianDayNumber: 0<br>
and obtain<br>
24 November -4713 (GregorianDate)<br>
instead of<br>
1 January -4712 (JulianDate)</p>
<p>In my little Calendrica project I made that distinction explicit but the implicit convention of understanding Date being GregorianDate is equally valid.<br>
It just needs a little bit more of text in the class comment.</p>
<p>HTH<br>
Ciao</p>
<div class="gmail_quote">On Jun 26, 2012 10:39 PM, "David T. Lewis" <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Enrico,<br>
<br>
The Chronology package in Squeak takes a simple point of view in that only<br>
one calender algorithm is in effect. Based on your experience with this<br>
topic, would you say that the algorithm that Bert has proposed is a good<br>
choice?<br>
<br>
It seems to me that it is an improvement because it produces the expected<br>
results for a wide range of users, and it does not break any existing<br>
assumptions in the system.<br>
<br>
Thanks<br>
Dave<br>
<br>
On Tue, Jun 26, 2012 at 10:18:56PM +0200, Enrico Spinielli wrote:<br>
> If you need to calculates dates in different calendars, the reference is<br>
> Nachum Dershowitz, Edward M. Reingold 'Calendrical Calculations' [1].<br>
> But beware of what you mean with 'historical' conversions: Gregorian<br>
> calendar was adopted at different times in different countries...<br>
><br>
> I have a literate programming based implementation in Python (an original<br>
> Lisp code of tge book side by side) at [2].<br>
><br>
> A Smaltalk implenentation is available at [3].<br>
><br>
> HTH<br>
> Bye<br>
> Enrico<br>
><br>
> [1]<br>
> <a href="http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/index.html" target="_blank">http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/index.html</a><br>
> [2] <a href="http://code.google.com/p/pycalcal/" target="_blank">http://code.google.com/p/pycalcal/</a><br>
> [3] <a href="http://www.squeaksource.com/Calendrica.html" target="_blank">http://www.squeaksource.com/Calendrica.html</a><br>
> On Jun 26, 2012 7:07 PM, "H. Hirzel" <<a href="mailto:hannes.hirzel@gmail.com">hannes.hirzel@gmail.com</a>> wrote:<br>
><br>
> > Great that Squeak will be in the position to calculate historical<br>
> > dates properly, so no objection at all.<br>
> ><br>
> > Thank you for your careful analysis and a synthesis of an algorithm<br>
> > which corrects the problem. I assume you description will be in a<br>
> > class comment...<br>
> ><br>
> > Hannes<br>
> ><br>
> > On 6/25/12, David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:<br>
> > > On Mon, Jun 25, 2012 at 01:54:08PM +0200, Bert Freudenberg wrote:<br>
> > >> Squeak dates are based on the Julian Day Number:<br>
> > >><br>
> > >> <a href="http://en.wikipedia.org/wiki/Julian_day" target="_blank">http://en.wikipedia.org/wiki/Julian_day</a><br>
> > >><br>
> > >> This is defined as the number of days since January 1, 4713 BC in the<br>
> > >> Julian proleptic calendar.<br>
> > >><br>
> > >> Now, to my surprise,<br>
> > >><br>
> > >> Date julianDayNumber: 0<br>
> > >><br>
> > >> answers<br>
> > >><br>
> > >> 24 November -4713<br>
> > >><br>
> > >> instead of<br>
> > >><br>
> > >> 1 January -4712<br>
> > >><br>
> > >> Digging into this it is because Squeak uses the Fliegel-Van Flandern<br>
> > >> algorithm, which always results in a Gregorian date. Even for dates<br>
> > before<br>
> > >> the Gregorian calendar was introduced. If we were to use the algorithm<br>
> > by<br>
> > >> Jean Meeus, dates before 15 Nov 1582 would be converted to a Julian<br>
> > date.<br>
> > >><br>
> > >> Meeus is a floating point algorithm which we may not want to use. I<br>
> > added<br>
> > >> a correction to our method similar to Meeus, but converted to integers.<br>
> > So<br>
> > >> this is a mixed one, pasted below.<br>
> > >><br>
> > >> Would anyone be opposed to adopt this? The behavior will be unchanged<br>
> > for<br>
> > >> all dates more recent than 15 Nov 1582.<br>
> > ><br>
> > > I can't think of any reason why this should cause problems, aside from<br>
> > the<br>
> > > need to make a couple of trivial updates to the unit tests. Perhaps Brent<br>
> > > can comment, but it looks to me like a good thing to do.<br>
> > ><br>
> > > Dave<br>
> > ><br>
> > ><br>
> > >><br>
> > >> If so, we also would need an adjustment for the reverse part in<br>
> > >> year:month:day:hour:minute:second:nanoSecond:offset:. This is already<br>
> > >> covered by a test using the year 1200 BC<br>
> > >> (DateAndTimeTest>>testFromString). Anybody up for making that work?<br>
> > >><br>
> > >> I stumbled upon this because Etoys 5 has a new Calendar object which<br>
> > >> exposes the Julian Day Number, and setting it to 0 is a very convenient<br>
> > >> way of explaining what that means.<br>
> > >><br>
> > >> Thanks!<br>
> > >><br>
> > >> - Bert -<br>
> > >><br>
> > >> dayMonthYearDo: aBlock<br>
> > >> "Evaluate the block with three arguments: day month, year.<br>
> > >> Uses the Fliegel-Van Flandern algorithm, with adjustment for dates<br>
> > before<br>
> > >> 15 Nov 1582 as given by Jean Meeus.<br>
> > >> See <a href="http://mathforum.org/library/drmath/view/51907.html" target="_blank">http://mathforum.org/library/drmath/view/51907.html</a>"<br>
> > >><br>
> > >> | a l n i j dd mm yyyy |<br>
> > >> a := jdn.<br>
> > >> a < 2299161 ifTrue: [ | alpha |<br>
> > >> alpha := (jdn * 4 - 7468865) // 146097.<br>
> > >> a := jdn - 1 - alpha + (alpha // 4)].<br>
> > >> l := a + 68569.<br>
> > >> n := 4 * l // 146097.<br>
> > >> l := l - (146097 * n + 3 // 4).<br>
> > >> i := 4000 * (l + 1) // 1461001.<br>
> > >> l := l - (1461 * i // 4) + 31.<br>
> > >> j := 80 * l // 2447.<br>
> > >> dd := l - (2447 * j // 80).<br>
> > >> l := j // 11.<br>
> > >> mm := j + 2 - (12 * l).<br>
> > >> yyyy := 100 * (n - 49) + i + l.<br>
> > >><br>
> > >> ^ aBlock<br>
> > >> value: dd<br>
> > >> value: mm<br>
> > >> value: yyyy<br>
> > >><br>
> > ><br>
> > ><br>
> ><br>
> ><br>
<br>
><br>
<br>
<br>
</blockquote></div>