[Haskell-cafe] dates...

Gregory Guthrie guthrie at miu.edu
Thu Aug 6 19:29:08 UTC 2020


AH, yes - thanks, that is the missing 13-days mystery?
And yes - in us MM/dd/yy is most common.
Thanks.


Dr. Gregory Guthrie
Maharishi International University
----------------------------------------------------------------

Subject: Re: [Haskell-cafe] dates...

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.


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/img/email-signature.png]<https://chordify.net/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200806/e19fce76/attachment-0001.html>


More information about the Haskell-Cafe mailing list