time-compat- Compatibility with old-time for the time package

Safe HaskellNone




Compatibility with the old-time package for the "new" time package.

This is useful for writing portable code; in particular, if you're using the http://hackage.haskell.org/package/directory package and you want your code to build with both GHC 7.6 and earlier versions. The version of directory used with GHC 7.6 changed a dependency from old-time to time which means its getModificationTime function now returns a UTCTime instead of a ClockTime. This type affects the public API of many libraries that use it. To make such libraries portable, port your code to use the time package and to only rely on UTCTime in its public API, and call toUTCTime on the values returned by functions like getModificationTime, for example:

fmap toUTCTime getModificationTime

If you're using directory-1.2, toUTCTime will just be id and the original value is returned intact. If you're using an older directory, for example because you're building with GHC 7.4, the ClockTime returned by getModificationTime will be converted to a UTCTime and will be compatible with your code ported to the new time package.


Converting between representations