[Haskell-cafe] dates...

Jeroen Bransen jeroen at chordify.net
Thu Aug 6 07:14:01 UTC 2020


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
> <https://hackage.haskell.org/package/time-1.6/docs/Data-Time-Calendar.html#t:Day>
> -> (Integer
> <https://hackage.haskell.org/package/base-4.8.1.0/docs/Prelude.html#t:Integer>,
> Int
> <https://hackage.haskell.org/package/base-4.8.1.0/docs/Data-Int.html#t: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
> <https://hackage.haskell.org/package/time-1.6/docs/Data-Time-Calendar.html#t:Day>
> -> (Integer
> <https://hackage.haskell.org/package/base-4.8.1.0/docs/Prelude.html#t:Integer>,
> Int
> <https://hackage.haskell.org/package/base-4.8.1.0/docs/Data-Int.html#t:Int>,
> Int
> <https://hackage.haskell.org/package/base-4.8.1.0/docs/Data-Int.html#t:Int>)
> Source
> <https://hackage.haskell.org/package/time-1.6/docs/src/Data-Time-Calendar-Julian.html#toJulian>
>
>     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


-- 
 <https://chordify.net>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200806/d10a1ab3/attachment.html>


More information about the Haskell-Cafe mailing list