[Haskell-cafe] dates...

Gregory Guthrie guthrie at miu.edu
Thu Aug 6 03:23:11 UTC 2020


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
----------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200806/81fb29dc/attachment.html>


More information about the Haskell-Cafe mailing list