RFC: Time Library 0.3

Ashley Yakeley ashley at semantic.org
Sun Mar 5 20:25:42 EST 2006


In article <91951618304.20060213182803 at HotPOP.com>,
 Bulat Ziganshin <bulatz at HotPOP.com> wrote:

> AY> Please take a look at my third draft of a replacement for the standard 
> AY> time library.
> AY> http://semantic.org/TimeLib/
> 
> afai understand, your library should replace "getClockTime"
> functionality, but it's not obvious what function what function one
> should use. how i can
> 
> 1) print difference between two wallclock times in form "Elapsed 3.024 
> seconds"

  do
    t0 <- getCurrentTime
    foo
    t1 <- getCurrentTime
    putStrLn ("Elapsed " ++ (show (diffUTCTime t1 t0)) ++ " seconds")

Of course, this will be off if the clock has had a leap-second step in 
between.

> 2) convert CTime (returned by stat() function) to the ClockTime analog
> and back. May be that is not intended use of your library, but i does
> it in order to "touch" files and print file's datetime stamp in the
> human-readable form

  import Data.Time.Clock.POSIX
  type Time_t = Integer
  fromTimeStamp :: Time_t -> UTCTime
  fromTimeStamp = posixSecondsToUTCTime . fromInteger
  toTimeStamp :: UTCTime -> Time_t
  toTimeStamp = truncate . utcTimeToPOSIXSeconds

> at the current moment your library really omits docs. that you have is
> comments to functions, why docs should be task-oriented

I have some use-cases here:
<http://semantic.org/TimeLib/TimeLib/time/test/UseCases.lhs>

-- 
Ashley Yakeley, Seattle WA
WWED? http://www.cs.utexas.edu/users/EWD/



More information about the Libraries mailing list