time-compat (empty) → 0.1.0
raw patch · 4 files changed
+111/−0 lines, 4 filesdep +basedep +old-timedep +timesetup-changed
Dependencies added: base, old-time, time
Files
- LICENSE +24/−0
- Setup.hs +2/−0
- src/Data/Time/Compat.hs +54/−0
- time-compat.cabal +31/−0
+ LICENSE view
@@ -0,0 +1,24 @@+Copyright (c) 2012, Dag Odenhall+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++* Redistributions of source code must retain the above copyright notice,+ this list of conditions and the following disclaimer.++* Redistributions in binary form must reproduce the above copyright notice,+ this list of conditions and the following disclaimer in the documentation+ and/or other materials provided with the distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Data/Time/Compat.hs view
@@ -0,0 +1,54 @@+{-# LANGUAGE RecordWildCards #-}++-- | Compatibility with the+-- <old-time http://hackage.haskell.org/package/old-time> package for the+-- \"new\" <time http://hackage.haskell.org/package/time> package.+--+-- This is useful for writing portable code; in particular, if you're+-- using the <directory 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 'Time.UTCTime' instead of+-- a 'OldTime.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 'Time.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+-- 'OldTime.ClockTime' returned by @getModificationTime@ will be+-- converted to a 'Time.UTCTime' and will be compatible with your code+-- ported to the new @time@ package.+module Data.Time.Compat+ ( -- * Converting between representations+ ToUTCTime(..)+ )+ where++import qualified Data.Time as Time+import qualified System.Time as OldTime++class ToUTCTime a where+ toUTCTime :: a -> Time.UTCTime++instance ToUTCTime Time.UTCTime where+ toUTCTime = id++instance ToUTCTime OldTime.ClockTime where+ toUTCTime = toUTCTime . OldTime.toUTCTime++instance ToUTCTime OldTime.CalendarTime where+ toUTCTime OldTime.CalendarTime{..} =+ Time.UTCTime day diffTime+ where+ year = fromIntegral ctYear+ month = fromEnum ctMonth+ day = Time.fromGregorian year month ctDay+ sec = ctHour*60^2 + ctMin*60 + ctSec+ pico = fromIntegral sec*10^12 + ctPicosec+ diffTime = Time.picosecondsToDiffTime pico
+ time-compat.cabal view
@@ -0,0 +1,31 @@+name : time-compat+version : 0.1.0+homepage : http://hub.darcs.net/dag/time-compat+bug-reports : http://hub.darcs.net/dag/time-compat/issues+category : System+cabal-version : >= 1.10+build-type : Simple++license : BSD3+license-file : LICENSE+author : Dag Odenhall+maintainer : dag.odenhall@gmail.com++synopsis : Compatibility with old-time for the time package+description : Compatibility with the+ <old-time http://hackage.haskell.org/package/old-time>+ package for the \"new\"+ <time http://hackage.haskell.org/package/time> package.++source-repository head+ type : darcs+ location : http://hub.darcs.net/dag/time-compat++library+ hs-source-dirs : src+ default-language : Haskell2010+ ghc-options : -Wall -fno-warn-type-defaults+ exposed-modules : Data.Time.Compat+ build-depends : base == 4.*,+ old-time,+ time