Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the date in Haskell in the local timezone

I am currently using the code below in a project
date :: IO (Integer,Int,Int) -- :: (year,month,day)
date = getCurrentTime >>= return . toGregorian . utctDay

However it does not give the correct local date when run. I have run this at 1am on the 26/04/11 yet the function results in (2011, 4, 25).
I understand that the utctDay refers to UTC and therefore isn't the local system date, but is it possible to get the same format of date as seen above but with the correct date depending on the machines system date?

like image 801
Ed George Avatar asked Apr 25 '11 23:04

Ed George


1 Answers

Try getZonedTime: http://hackage.haskell.org/packages/archive/time/1.2.0.4/doc/html/Data-Time-LocalTime.html#v:getZonedTime

like image 51
sclv Avatar answered Sep 19 '22 01:09

sclv