<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, &quot;David T. Lewis&quot; &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt; 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>
&gt; If you need to calculates dates in different calendars, the reference is<br>
&gt; Nachum Dershowitz, Edward M. Reingold  &#39;Calendrical Calculations&#39; [1].<br>
&gt; But beware of what you mean with &#39;historical&#39; conversions: Gregorian<br>
&gt; calendar was adopted at different times in different countries...<br>
&gt;<br>
&gt; I have a literate programming based implementation in Python (an original<br>
&gt; Lisp code of tge book side by side) at [2].<br>
&gt;<br>
&gt; A Smaltalk implenentation is available at [3].<br>
&gt;<br>
&gt; HTH<br>
&gt; Bye<br>
&gt; Enrico<br>
&gt;<br>
&gt; [1]<br>
&gt; <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>
&gt; [2] <a href="http://code.google.com/p/pycalcal/" target="_blank">http://code.google.com/p/pycalcal/</a><br>
&gt; [3] <a href="http://www.squeaksource.com/Calendrica.html" target="_blank">http://www.squeaksource.com/Calendrica.html</a><br>
&gt; On Jun 26, 2012 7:07 PM, &quot;H. Hirzel&quot; &lt;<a href="mailto:hannes.hirzel@gmail.com">hannes.hirzel@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; Great that Squeak will be in the position to calculate historical<br>
&gt; &gt; dates properly, so no objection at all.<br>
&gt; &gt;<br>
&gt; &gt; Thank you for your careful analysis and a synthesis of an algorithm<br>
&gt; &gt; which corrects the problem. I assume you description will be in a<br>
&gt; &gt; class comment...<br>
&gt; &gt;<br>
&gt; &gt; Hannes<br>
&gt; &gt;<br>
&gt; &gt; On 6/25/12, David T. Lewis &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt; wrote:<br>
&gt; &gt; &gt; On Mon, Jun 25, 2012 at 01:54:08PM +0200, Bert Freudenberg wrote:<br>
&gt; &gt; &gt;&gt; Squeak dates are based on the Julian Day Number:<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt;      <a href="http://en.wikipedia.org/wiki/Julian_day" target="_blank">http://en.wikipedia.org/wiki/Julian_day</a><br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; This is defined as the number of days since January 1, 4713 BC in the<br>
&gt; &gt; &gt;&gt; Julian proleptic calendar.<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; Now, to my surprise,<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt;      Date julianDayNumber: 0<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; answers<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt;      24 November -4713<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; instead of<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt;      1 January -4712<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; Digging into this it is because Squeak uses the Fliegel-Van Flandern<br>
&gt; &gt; &gt;&gt; algorithm, which always results in a Gregorian date. Even for dates<br>
&gt; &gt; before<br>
&gt; &gt; &gt;&gt; the Gregorian calendar was introduced. If we were to use the algorithm<br>
&gt; &gt; by<br>
&gt; &gt; &gt;&gt; Jean Meeus, dates before 15 Nov 1582 would be converted to a Julian<br>
&gt; &gt; date.<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; Meeus is a floating point algorithm which we may not want to use. I<br>
&gt; &gt; added<br>
&gt; &gt; &gt;&gt; a correction to our method similar to Meeus, but converted to integers.<br>
&gt; &gt; So<br>
&gt; &gt; &gt;&gt; this is a mixed one, pasted below.<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; Would anyone be opposed to adopt this? The behavior will be unchanged<br>
&gt; &gt; for<br>
&gt; &gt; &gt;&gt; all dates more recent than 15 Nov 1582.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I can&#39;t think of any reason why this should cause problems, aside from<br>
&gt; &gt; the<br>
&gt; &gt; &gt; need to make a couple of trivial updates to the unit tests. Perhaps Brent<br>
&gt; &gt; &gt; can comment, but it looks to me like a good thing to do.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Dave<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; If so, we also would need an adjustment for the reverse part in<br>
&gt; &gt; &gt;&gt; year:month:day:hour:minute:second:nanoSecond:offset:. This is already<br>
&gt; &gt; &gt;&gt; covered by a test using the year 1200 BC<br>
&gt; &gt; &gt;&gt; (DateAndTimeTest&gt;&gt;testFromString). Anybody up for making that work?<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; I stumbled upon this because Etoys 5 has a new Calendar object which<br>
&gt; &gt; &gt;&gt; exposes the Julian Day Number, and setting it to 0 is a very convenient<br>
&gt; &gt; &gt;&gt; way of explaining what that means.<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; Thanks!<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; - Bert -<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt; dayMonthYearDo: aBlock<br>
&gt; &gt; &gt;&gt;      &quot;Evaluate the block with three arguments: day month, year.<br>
&gt; &gt; &gt;&gt;      Uses the Fliegel-Van Flandern algorithm, with adjustment for dates<br>
&gt; &gt; before<br>
&gt; &gt; &gt;&gt; 15 Nov 1582 as given by Jean Meeus.<br>
&gt; &gt; &gt;&gt;      See <a href="http://mathforum.org/library/drmath/view/51907.html" target="_blank">http://mathforum.org/library/drmath/view/51907.html</a>&quot;<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt;      | a l n i j dd mm yyyy |<br>
&gt; &gt; &gt;&gt;      a := jdn.<br>
&gt; &gt; &gt;&gt;      a &lt; 2299161 ifTrue: [ | alpha |<br>
&gt; &gt; &gt;&gt;              alpha := (jdn * 4 - 7468865) // 146097.<br>
&gt; &gt; &gt;&gt;              a := jdn - 1 - alpha + (alpha // 4)].<br>
&gt; &gt; &gt;&gt;      l := a + 68569.<br>
&gt; &gt; &gt;&gt;      n := 4 * l // 146097.<br>
&gt; &gt; &gt;&gt;      l := l - (146097 * n + 3 // 4).<br>
&gt; &gt; &gt;&gt;      i := 4000 * (l + 1) // 1461001.<br>
&gt; &gt; &gt;&gt;      l := l - (1461 * i // 4) + 31.<br>
&gt; &gt; &gt;&gt;      j := 80 * l // 2447.<br>
&gt; &gt; &gt;&gt;      dd := l - (2447 * j // 80).<br>
&gt; &gt; &gt;&gt;      l := j // 11.<br>
&gt; &gt; &gt;&gt;      mm := j + 2 - (12 * l).<br>
&gt; &gt; &gt;&gt;      yyyy := 100 * (n - 49) + i + l.<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;&gt;      ^ aBlock<br>
&gt; &gt; &gt;&gt;              value: dd<br>
&gt; &gt; &gt;&gt;              value: mm<br>
&gt; &gt; &gt;&gt;              value: yyyy<br>
&gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
<br>
&gt;<br>
<br>
<br>
</blockquote></div>