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