packages feed

hourglass 0.2.8 → 0.2.9

raw patch · 10 files changed

+34/−19 lines, 10 filesdep ~base

Dependency ranges changed: base

Files

Data/Hourglass/Format.hs view
@@ -10,6 +10,7 @@ -- Built-in format strings -- {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeSynonymInstances #-} module Data.Hourglass.Format     (     -- * Parsing and Printing@@ -76,7 +77,7 @@     }  instance Show TimeFormatFct where-    show f = timeFormatFctName f+    show = timeFormatFctName instance Eq TimeFormatFct where     t1 == t2 = timeFormatFctName t1 == timeFormatFctName t2 @@ -312,7 +313,7 @@             | allDigits [h1,h2,m1,m2] = let tz = toTZ isNeg h1 h2 m1 m2                                          in Right (modTZ (const tz) acc, xs)             | otherwise               = Left ("not digits chars: " ++ show [h1,h2,m1,m2])-        parseHM _ _    _ _ = Left ("invalid timezone format")+        parseHM _ _    _ _ = Left "invalid timezone format"          toTZ isNeg h1 h2 m1 m2 = TimezoneOffset ((if isNeg then negate else id) minutes)           where minutes = (toInt [h1,h2] * 60) + toInt [m1,m2]
Data/Hourglass/Internal.hs view
@@ -7,10 +7,7 @@ -- -- System lowlevel functions ---{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE CPP #-}-{-# LANGUAGE EmptyDataDecls #-}- module Data.Hourglass.Internal     ( dateTimeFromUnixEpochP     , dateTimeFromUnixEpoch
Data/Hourglass/Internal/Unix.hs view
@@ -50,8 +50,13 @@   where sofTimespec = sofCTime + sofCLong         sofCTime = sizeOf (0 :: CTime)         sofCLong = sizeOf (0 :: CLong)+#if (MIN_VERSION_base(4,5,0))         toElapsedP :: CTime -> CLong -> ElapsedP         toElapsedP (CTime sec) nsec = ElapsedP (Elapsed $ Seconds (fromIntegral sec)) (fromIntegral nsec)+#else+        toElapsedP :: CLong -> CLong -> ElapsedP+        toElapsedP sec         nsec = ElapsedP (Elapsed $ Seconds (fromIntegral sec)) (fromIntegral nsec)+#endif  -- | return the current elapsed systemGetElapsed :: IO Elapsed@@ -59,17 +64,30 @@     c_clock_get ptr     toElapsed <$> peek (castPtr ptr)   where sofTimespec = sizeOf (0 :: CTime) + sizeOf (0 :: CLong)+#if (MIN_VERSION_base(4,5,0))         toElapsed :: CTime -> Elapsed         toElapsed (CTime sec) = Elapsed $ Seconds (fromIntegral sec)+#else+        toElapsed :: CLong -> Elapsed+        toElapsed sec         = Elapsed $ Seconds (fromIntegral sec)+#endif  foreign import ccall unsafe "hourglass_clock_calendar"     c_clock_get :: Ptr CLong -> IO () +#if (MIN_VERSION_base(4,5,0)) foreign import ccall unsafe "gmtime_r"     c_gmtime_r :: Ptr CTime -> Ptr CTm -> IO (Ptr CTm)  foreign import ccall unsafe "localtime_r"     c_localtime_r :: Ptr CTime -> Ptr CTm -> IO (Ptr CTm)+#else+foreign import ccall unsafe "gmtime_r"+    c_gmtime_r :: Ptr CLong -> Ptr CTm -> IO (Ptr CTm)++foreign import ccall unsafe "localtime_r"+    c_localtime_r :: Ptr CLong -> Ptr CTm -> IO (Ptr CTm)+#endif  -- | Return a global time's struct tm based on the number of elapsed second since unix epoch. rawGmTime :: Elapsed -> CTm
Data/Hourglass/Internal/Win.hs view
@@ -49,7 +49,7 @@             DateTime (Date (fi wY) (toEnum $ fi $ wM - 1) (fi wD))                      (TimeOfDay (fi wH) (fi wMin) (fi wS) ns)         fi :: (Integral a, Num b) => a -> b-        fi x = fromIntegral x+        fi = fromIntegral  dateTimeFromUnixEpoch :: Elapsed -> DateTime dateTimeFromUnixEpoch e = toDateTime $ callSystemTime e@@ -57,7 +57,7 @@             DateTime (Date (fi wY) (toEnum $ fi $ wM - 1) (fi wD))                      (TimeOfDay (fi wH) (fi wMin) (fi wS) 0)         fi :: (Integral a, Num b) => a -> b-        fi x = fromIntegral x+        fi = fromIntegral  systemGetTimezone :: IO TimezoneOffset systemGetTimezone = do
Data/Hourglass/Local.hs view
@@ -1,6 +1,3 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE FlexibleInstances #-} -- | -- Module      : Data.Hourglass.Local -- License     : BSD-style@@ -10,6 +7,7 @@ -- -- Local time = global time + timezone --+{-# LANGUAGE FlexibleInstances #-} module Data.Hourglass.Local     (     -- * Local time@@ -73,7 +71,7 @@  -- | create a local time value from a global one localTimeFromGlobal :: Time t => t -> LocalTime t-localTimeFromGlobal t = localTime (TimezoneOffset 0) t+localTimeFromGlobal = localTime (TimezoneOffset 0)  -- | Change the timezone, and adjust the local value to represent the new local value. localTimeSetTimezone :: Time t => TimezoneOffset -> LocalTime t -> LocalTime t
Data/Hourglass/Time.hs view
@@ -8,9 +8,10 @@ -- generic time representation interface to allow -- arbitrary conversion between different time representation ---{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Data.Hourglass.Time     (     -- * Generic time classes@@ -36,6 +37,7 @@     , timeAdd     , timeDiff     , timeDiffP+    , dateAddPeriod     ) where  import Data.Data ()@@ -86,6 +88,7 @@     timeFromElapsed :: Elapsed -> t     timeFromElapsed e = timeFromElapsedP (ElapsedP e 0) +#if (MIN_VERSION_base(4,5,0)) instance Timeable CTime where     timeGetElapsedP c         = ElapsedP (timeGetElapsed c) 0     timeGetElapsed  (CTime c) = Elapsed (Seconds $ fromIntegral c)@@ -93,6 +96,7 @@ instance Time CTime where     timeFromElapsedP (ElapsedP e _)       = timeFromElapsed e     timeFromElapsed (Elapsed (Seconds c)) = CTime (fromIntegral c)+#endif  instance Timeable Elapsed where     timeGetElapsedP  e = ElapsedP e 0
Data/Hourglass/Types.hs view
@@ -201,7 +201,7 @@  instance Show TimezoneOffset where     show (TimezoneOffset tz) =-        concat [(if tz < 0 then "-" else "+"), pad2 tzH, pad2 tzM]+        concat [if tz < 0 then "-" else "+", pad2 tzH, pad2 tzM]       where (tzH, tzM) = abs tz `divMod` 60  -- | The UTC timezone. offset of 0
Data/Hourglass/Zone.hs view
@@ -48,5 +48,5 @@     : (pad0 h ++ ":" ++ pad0 m)   where (h,m)  = abs offset `divMod` 60         pad0 v-            | v < 10    = ('0':show v)-            | otherwise = (show v)+            | v < 10    = '0':show v+            | otherwise = show v
hourglass.cabal view
@@ -1,5 +1,5 @@ Name:                hourglass-Version:             0.2.8+Version:             0.2.9 Synopsis:            simple performant time related library Description:     Simple time library focusing on simple but powerful and performant API
tests/Tests.hs view
@@ -5,8 +5,6 @@ module Main where  import Control.Applicative-import Data.Monoid (mempty)---import Control.DeepSeq  import Test.Tasty import Test.Tasty.QuickCheck@@ -16,7 +14,6 @@ import Data.Int import Data.Hourglass import Data.Hourglass.Epoch---import System.Hourglass  import Foreign.Storable import Foreign.C.Types (CTime)