Dear Gregory,

According to [1]:
> For any given event during the years from 1901 to 2099 inclusive, its date according to the Julian calendar is 13 days behind its corresponding Gregorian date.

And 13 days before 2020-01-08 is indeed 2019-12-26, which is the 360th day of the year 2019, so I am not sure about your confusion. If you pick a date in the first 13 days of the year, then the Julian conversion will indeed lead to a date in the year before.

Maybe you are thinking about August the 1st? Your date parsing, with month coming first, is odd for most parts of the world; the date you are parsing in the example is the 8th of January in the year 2020.

Regards,
Jeroen Bransen


[1] https://en.wikipedia.org/wiki/Julian_calendar

Op 6-8-2020 om 05:23 schreef Gregory Guthrie:

I don’t understand why the Julian conversion are given relative to 2019, instead of 2020, and don’t seem to actually show the date index.

Must be misreading the library specs?

toJulianYearAndDay :: Day -> (Integer, Int)

     convert to proleptic Julian year and day format. First element of result is year (proleptic Julian calendar), second is the day of the year, with 1 for Jan 1, and 365

toJulian :: Day -> (Integer, Int, Int) Source

    convert to proleptic Julian calendar. First element of result is year, second month number (1-12), third day (1-31).

----------------------------------------------------------------------------------

 

ds = "1/8/2020"

day = parseTimeOrError True defaultTimeLocale "%-m/%-d/%Y"   ds :: UTCTime

 

getDay       = toGregorian       . utctDay

getDayOfYear = toJulian          . utctDay

getDayYear   = toJulianYearAndDay. utctDay

 

main = do

      print day

      print $ getDay       day

      print $ getDayYear   day

      print $ getDayOfYear day

 

2020-01-08 00:00:00 UTC

(2020,1,8)

(2019,360)

(2019,12,26)

And;

2020-02-08 00:00:00 UTC

(2020,2,8)

(2020,26)

(2020,1,26)

 

Dr. Gregory Guthrie

Maharishi International University

----------------------------------------------------------------

 


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

-- 
Jeroen Bransen
Lead Back-end Developer at Chordify