[Haskell-cafe] bug in time libs?
sam lee
skynare at gmail.com
Mon Dec 1 22:30:20 EST 2008
I can't find document for System.Time .
But I can import System.Time . It's weird...
I can't find document for TimeDiff and related functions. I guess this
is all deprecated.
A related bug report: http://hackage.haskell.org/trac/ghc/ticket/2519
I would use Data.Time.Clock
Prelude> :m + Data.Time.Clock
Prelude Data.Time.Clock> getCurrentTime
Prelude Data.Time.Clock> t0 <- getCurrentTime
Prelude Data.Time.Clock> t1 <- getCurrentTime
Prelude Data.Time.Clock> t0
Prelude Data.Time.Clock> diffUTCTime t0 t1
-2.912s
Prelude Data.Time.Clock> diffUTCTime t1 t0
2.912s
Prelude Data.Time.Clock> :t diffUTCTime t1 t0
diffUTCTime t1 t0 :: NominalDiffTime
On Mon, Dec 1, 2008 at 10:05 PM, Jason Dusek <jason.dusek at gmail.com> wrote:
> I'm on 6.10.1, using the libs provided with the binary of GHC
> for Mac OS X. I was fooling around with the time package in
> GHCi and something seems to be off. I have included a
> transcript.
>
> If I take a time diff, then the seconds are positive when the
> picos are negative and vice versa.
>
> --
> _jsn
>
>
> |...transcript...|
>
>
> Prelude System.Time> :m + System.Time
> Prelude System.Time> t0 <- System.Time.getClockTime
> Prelude System.Time> t1 <- System.Time.getClockTime
> Prelude System.Time> diffClockTimes t0 t1
> TimeDiff { tdYear = 0
> , tdMonth = 0
> , tdDay = 0
> , tdHour = 0
> , tdMin = 0
> , tdSec = -7
> , tdPicosec = 238846000000
> }
> Prelude System.Time> diffClockTimes t1 t0
> TimeDiff { tdYear = 0
> , tdMonth = 0
> , tdDay = 0
> , tdHour = 0
> , tdMin = 0
> , tdSec = 7
> , tdPicosec = -238846000000
> }
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list