[Haskell-beginners] get date

Brandon S Allbery KF8NH allbery at ece.cmu.edu
Thu Jun 24 10:08:50 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/24/10 03:52 , Luca Ciciriello wrote:
> Just a question.
> How can I obtain a String from
> 
> currentTime :: IO Day
> currentTime =  utctDay `fmap` getCurrentTime
> 
> Here currentTime returns to me 2010-06-24, but I want "2010-06-24".
> In another worlds I need a function 
> 
> currentTimeStr :: IO Day -> String

You can't escape from IO, but you can lift a formatter into IO.  Formatters
are in Data.Time.Format; look at the documentation for your system's
strftime() function to see how it works.

- -- 
brandon s. allbery     [linux,solaris,freebsd,perl]      allbery at kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university      KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwjZuIACgkQIn7hlCsL25UwpgCfRuhCW5sB9G8Ud9Ci3JUZbVTt
vAIAn3CFOoX9Q4etASv3ggC8KFxm94W6
=ZUFJ
-----END PGP SIGNATURE-----


More information about the Beginners mailing list