packages feed

hourglass 0.2.10 → 0.2.11

raw patch · 8 files changed

+57/−12 lines, 8 filesdep +gaugedep −criteriondep ~base

Dependencies added: gauge

Dependencies removed: criterion

Dependency ranges changed: base

Files

CHANGELOG.md view
@@ -1,3 +1,19 @@+## Version 0.2.11 (2018-02-04)++- Add Zero UTC+- Avoid division by 0+- Add support for ghc-8.4 alpha2++## Version 0.2.10 (2016-02-27)++- Move towards Time. hierarchy+- Add some test+- Fix some issues++## Version 0.2.9 (2015-04-01)++- some tidy up+ ## Version 0.2.8 (2015-01-07)  - Fix test with time 1.5
Data/Hourglass.hs view
@@ -30,6 +30,7 @@     , isLeapYear     , getWeekDay     , getDayOfTheYear+    , daysInMonth     ) where  import Data.Hourglass.Time
Data/Hourglass/Diff.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} -- | -- Module      : Data.Hourglass.Diff@@ -38,6 +39,11 @@  instance NFData Period where     rnf (Period y m d) = y `seq` m `seq` d `seq` ()+#if (MIN_VERSION_base(4,11,0))+instance Semigroup Period where+    (<>) (Period y1 m1 d1) (Period y2 m2 d2) =+        Period (y1+y2) (m1+m2) (d1+d2)+#endif instance Monoid Period where     mempty = Period 0 0 0     mappend (Period y1 m1 d1) (Period y2 m2 d2) =@@ -54,6 +60,11 @@  instance NFData Duration where     rnf (Duration h m s ns) = h `seq` m `seq` s `seq` ns `seq` ()+#if (MIN_VERSION_base(4,11,0))+instance Semigroup Duration where+    (<>) (Duration h1 m1 s1 ns1) (Duration h2 m2 s2 ns2) =+        Duration (h1+h2) (m1+m2) (s1+s2) (ns1+ns2)+#endif instance Monoid Duration where     mempty = Duration 0 0 0 0     mappend (Duration h1 m1 s1 ns1) (Duration h2 m2 s2 ns2) =
Data/Hourglass/Format.hs view
@@ -61,6 +61,7 @@     | Format_Precision Int -- ^ sub seconds display with a precision of N digits. with N between 1 and 9     | Format_TimezoneName   -- ^ timezone name (e.g. GMT, PST). not implemented yet     -- | Format_TimezoneOffset -- ^ timeoffset offset (+02:00)+    | Format_TzHM_Colon_Z -- ^ zero UTC offset (Z) or timeoffset with colon (+02:00)     | Format_TzHM_Colon -- ^ timeoffset offset with colon (+02:00)     | Format_TzHM       -- ^ timeoffset offset (+0200)     | Format_Tz_Offset  -- ^ timeoffset in minutes@@ -153,7 +154,7 @@         [Format_Year,dash,Format_Month2,dash,Format_Day2 -- date         ,Format_Text 'T'         ,Format_Hour,colon,Format_Minute,colon,Format_Second -- time-        ,Format_TzHM_Colon -- timezone offset with colon +HH:MM+        ,Format_TzHM_Colon_Z -- zero UTC offset (Z) or timezone offset with colon +HH:MM         ]       where dash = Format_Text '-'             colon = Format_Text ':'@@ -202,6 +203,9 @@         fmtToString Format_TimezoneName   = "" --         fmtToString Format_Tz_Offset = show tz         fmtToString Format_TzHM = show tzOfs+        fmtToString Format_TzHM_Colon_Z+            | tz == 0   = "Z"+            | otherwise = fmtToString Format_TzHM_Colon         fmtToString Format_TzHM_Colon =             let (tzH, tzM) = abs tz `divMod` 60                 sign = if tz < 0 then "-" else "+"@@ -290,6 +294,9 @@             onSuccess (\sec ->                 let newDate = dateTimeFromUnixEpochP $ flip ElapsedP 0 $ Elapsed $ Seconds sec                  in modDT (const newDate) acc) $ isNumber s+        processOne acc Format_TzHM_Colon_Z a@(c:s)+            | c == 'Z'  = Right (acc, s)+            | otherwise = processOne acc Format_TzHM_Colon a         processOne acc Format_TzHM_Colon (c:s) =             parseHMSign True acc c s         processOne acc Format_TzHM (c:s) =
Time/Types.hs view
@@ -149,6 +149,8 @@  instance Real ElapsedP where     -- FIXME+    toRational (ElapsedP (Elapsed (Seconds s)) (NanoSeconds 0)) =+        fromIntegral s     toRational (ElapsedP (Elapsed (Seconds s)) (NanoSeconds ns)) =         fromIntegral s + (1000000000 % fromIntegral ns) 
hourglass.cabal view
@@ -1,5 +1,5 @@ Name:                hourglass-Version:             0.2.10+Version:             0.2.11 Synopsis:            simple performant time related library Description:     Simple time library focusing on simple but powerful and performant API@@ -77,7 +77,7 @@   Default-Language:  Haskell2010   Build-depends:     base >= 4 && < 5                    , bytestring-                   , criterion+                   , gauge                    , mtl                    , deepseq                    , hourglass
tests/Bench.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE BangPatterns #-} module Main (main) where -import Criterion.Main+import Gauge.Main import Data.Hourglass import System.Hourglass import TimeDB
tests/Tests.hs view
@@ -53,12 +53,9 @@  -- | The @Date@ type is able to represent some values that aren't actually legal, -- specifically dates with a day field outside of the range of dates in the--- month. This function validates a @Date@. It is conservative; it only verifies--- that the day is less than 31. TODO: It would be nice to tighten this up a--- bit. There's a daysInMonth function we could use for this,--- but Data.Hourglass.Calendar, but it isn't exposed.+-- month. This function validates a @Date@. isValidDate :: Date -> Bool-isValidDate (Date _ _ d) = d > 0 && d <= 31+isValidDate (Date y m d) = d > 0 && d <= (daysInMonth y m)  -- windows native functions to convert time cannot handle time before year 1601 #ifdef WINDOWS@@ -105,9 +102,10 @@ instance Arbitrary DateTime where     arbitrary = DateTime <$> arbitrary <*> arbitrary instance Arbitrary Date where-    arbitrary = Date <$> choose dateRange-                     <*> arbitrary-                     <*> choose (1,28)+    arbitrary = do+        year <- choose dateRange+        month <- arbitrary+        Date year month <$> choose (1, daysInMonth year month) instance Arbitrary TimeOfDay where     arbitrary = TimeOfDay <$> (Hours <$> choose (0,23))                           <*> (Minutes <$> choose (0,59))@@ -192,6 +190,10 @@                 (toEnum ((fromEnum m+1) `mod` 12) `eq` m')        &&                 (if m == December then (y+1) `eq` y' else y `eq` y')                 -}++        -- Make sure our Arbitrary instance only generates valid dates:+        , testProperty "Arbitrary-isValidDate" isValidDate+         , testProperty "dateAddPeriod" $ (\date period ->             isValidDate (date `dateAddPeriod` period))         ]@@ -221,6 +223,12 @@                 _                     -> error "Cannot parse timezone"         , testProperty "custom-1" $ test_property_format ("YYYY-MM-DDTH:MI:S.msusns" :: String)         , testProperty "custom-2" $ test_property_format ("Mon DD\\t\\h YYYY at HH\\hMI\\mS\\s.p9\\n\\s" :: String)+        ]+    , testGroup "Regression Tests"+        [ testCase  "Real instance of ElapsedP (#33)" $+            let res = toRational (ElapsedP (Elapsed $ Seconds 0) (NanoSeconds 0))+                ref = toRational 0 :: Rational+             in assertEqual "failed equality" ref res         ]     ]   where toCalendarTest (i, (us, dt)) =