haskell / time

A time library
http://hackage.haskell.org/package/time
Other
118 stars 78 forks source link

Unexpected Julian dates #258

Closed bens closed 2 months ago

bens commented 2 months ago
ghci> Data.Time.Calendar.Julian.fromJulian 1900 1 1
1900-01-13
ghci> Data.Time.Calendar.Julian.fromJulian 2000 1 1
2000-01-14
ghci> Data.Time.Calendar.Julian.fromJulian 2000 1 2
2000-01-15
ghci> Data.Time.Calendar.Julian.fromJulian 2000 1 31
2000-02-13

These results seems unexpected to me, the parsed dates are shifted forward in time by thirteen days, usually, except the 1900 example is twelve days, I couldn't find any other examples of that from a quick try. Other years seem to be thirteen days as well.

bens commented 2 months ago

~Ah, this is in time-1.12.2, I'll try in HEAD first.~

Same result in HEAD.

AshleyYakeley commented 2 months ago

The Gregorian leap rule is every four years, except every 100 years, except every 400 years.

The Julian leap rule is every four years.

Thus, 1900 is a Julian leap year but not a Gregorian leap year. Your first example is before the Julian leap day of 1900, while the others are after.

AshleyYakeley commented 2 months ago

You can check here, but be sure to "Specify the month and day that the Julian year number was incremented" as January 1.

bens commented 2 months ago

Good grief, sorry for the noise, I was in a hurry and got Julian and Gregorian confused. Closing.