Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Haskell library for dates?

Tags:

date

haskell

Is there a function in Haskell that will allow me to enter component of a date (like a string representation or day month year components) that I can get information from (like day of week, days in a month, etc.)?

I've looked online and it looks like there are a lot of custom libraries, but I'm hoping there's one in the standard prelude library of ghci 10.6.4 that's just not well documented?

like image 922
Fry Avatar asked Jan 10 '10 01:01

Fry


2 Answers

Are Data.Time.Calendar and Data.Time.Format in the time library sufficient?

You can parse a string representation of a date and get the length of a month using gregorianMonthLength. Not sure about day of the week, though you could format the date as a string using a format that just displays the week day.

like image 143
Dan Dyer Avatar answered Sep 20 '22 13:09

Dan Dyer


A quick Google search turns up this, which may be what you want. It lets you parse strings representing dates and extract information from them.

like image 44
avpx Avatar answered Sep 18 '22 13:09

avpx