Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Haskell-cafe] Getting the number of seconds since epoch from System.Time.ClockTime

233 views
Skip to first unread message

Martin Percossi

unread,
Apr 26, 2007, 10:19:50 AM4/26/07
to haskel...@haskell.org
Hello haskell-cafe,

In System.Time,

data ClockTime = TOD Integer Integer

, where the first integer represents the number of seconds since epoch,
and the other represents the number of picoseconds. Is there a way of
retrieving the first part? (In Haskell 98, the ClockTime type is abstract).

TIA
Martin

My music: http://www.youtube.com/profile?user=thetonegrove
_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Simon Marlow

unread,
Apr 30, 2007, 8:12:14 AM4/30/07
to haskel...@martinpercossi.com
Martin Percossi wrote:
> Hello haskell-cafe,
>
> In System.Time,
>
> data ClockTime = TOD Integer Integer
>
> , where the first integer represents the number of seconds since epoch,
> and the other represents the number of picoseconds. Is there a way of
> retrieving the first part? (In Haskell 98, the ClockTime type is abstract).

Better to use the new time package, in particular Data.Time.Clock.POSIX:

http://www.haskell.org/ghc/docs/latest/html/libraries/time/Data-Time-Clock-POSIX.html

getPOSIXTime will do what you want.

Cheers,
Simon

Rich Neswold

unread,
May 1, 2007, 2:00:43 PM5/1/07
to haskel...@martinpercossi.com
On 4/26/07, Martin Percossi <haskel...@martinpercossi.com> wrote:
> In System.Time,
>
> data ClockTime = TOD Integer Integer
>
> , where the first integer represents the number of seconds since epoch,
> and the other represents the number of picoseconds. Is there a way of
> retrieving the first part? (In Haskell 98, the ClockTime type is
abstract).

I usually pattern match the constructor:

do { TOD epoch _ <- getClockTime
; putStrLn $ "epoch is " ++ show epoch }

--
Rich

AIM : rnezzy
ICQ : 174908475
Jabber: ri...@neswold.homeunix.net

0 new messages