[Haskell-beginners] get date

Felipe Lessa felipe.lessa at gmail.com
Wed Jun 23 14:13:44 EDT 2010


On Wed, Jun 23, 2010 at 08:03:16PM +0200, Luca Ciciriello wrote:
> How can I get the current system date-time in Haskell?
>
> I've used the library Time, but on MacOS X 10.6.4 the year is always 0.
>
> Luca.

Do you mean, you used getCurrentTime from the time package[1]?
What does the following line do?

  (toGregorian . utctDay) `fmap` getCurrentTime

On my system,

  GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
  Loading package ghc-prim ... linking ... done.
  Loading package integer ... linking ... done.
  Loading package base ... linking ... done.
  Prelude> :m Data.Time
  Prelude Data.Time> (toGregorian . utctDay) `fmap` getCurrentTime
  Loading package old-locale-1.0.0.1 ... linking ... done.
  Loading package time-1.1.4 ... linking ... done.
  (2010,6,23)

http://hackage.haskell.org/packages/archive/time/1.2.0.3/doc/html/Data-Time-Clock.html#v%3AgetCurrentTime

HTH,

--
Felipe.


More information about the Beginners mailing list