packages feed

hora 1.1 → 1.1.1

raw patch · 6 files changed

+72/−13 lines, 6 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Time.Hora.Timestamp: now :: IO (DatePart Int)
+ Data.Time.Hora.Timestamp: now :: Num a => IO (DatePart a)
- Data.Time.Hora.Timestamp: now' :: IO (Tz (DatePart Int))
+ Data.Time.Hora.Timestamp: now' :: Num a => IO (Tz (DatePart a))

Files

changelog.md view
@@ -1,3 +1,8 @@+#####   1.1.1+    Bug fix: Ord datePart+    +    Timestamp now -> Num+ #####   1.1     API overhaul     
hora.cabal view
@@ -1,5 +1,5 @@ name:                hora-version:             1.1+version:             1.1.1 build-type:          Simple cabal-version:       >=1.10 @@ -51,6 +51,7 @@                         RecordWildCards                         DeriveGeneric                         DeriveFunctor+                        MultiWayIf   test-suite spec@@ -72,6 +73,7 @@                         RecordWildCards                         DeriveGeneric                         DeriveFunctor+                        MultiWayIf    main-is: Main.hs   other-modules:@@ -82,6 +84,8 @@           Test.TestDmyHm           Test.TestPico           Test.TestPico2+          Test.TestDatePart+    build-depends:  base >= 4.8,                   hspec >= 2.1.7,
src/Data/Time/Hora/Timestamp.hs view
@@ -19,7 +19,7 @@ >>> now DatePart {year = 2016, month = 12, day = 14, hour = 9, minute = 7, second = 10, pico = 233275605000} -}-now::IO (DatePart Int)+now::Num a => IO (DatePart a) now = withUTCTime parse  @@ -28,7 +28,7 @@ >>> now' Tz CET (DatePart {year = 2016, month = 12, day = 14, hour = 10, minute = 7, second = 26, pico = 498313115000}) -}-now'::IO (Tz (DatePart Int))+now'::Num a => IO (Tz (DatePart a)) now' = withTimeZone parse'  
src/Data/Time/Hora/Type/DatePart.hs view
@@ -32,13 +32,24 @@    instance Ord (DatePart Int) where-    (<=) a0 b0 = not $  -        year a0 > (year b0)-        || month a0 > (month b0)-        || day a0 > (day b0)-        || hour a0 > (hour b0)-        || minute a0 > (minute b0)-        || second a0 > (second b0)-        || pico a0 > (pico b0)-         -            +    (<=) a0 b0 = +        let y1 = (year a0, year b0) +            m1 = (month a0, month b0) +            d1 = (day a0, day b0)+            h1 = (hour a0, hour b0) +            min1 = (minute a0, minute b0) +            s1 = (second a0, second b0) +            p1 = (pico a0, pico b0) +            l1 = [y1,m1,d1,h1,min1,s1,p1]+            f1 (Stop bo1) _ = Stop bo1 +            f1 Continue (a1, b1)  +                | a1 < b1 = Stop True   +                | a1 == b1 = Continue   +                | a1 > b1 = Stop False+            res2 = foldl f1 Continue l1+        in case res2 of +                Continue -> True+                (Stop b2) -> b2   +++data Ord_ = Stop Bool | Continue 
test/Main.hs view
@@ -7,6 +7,7 @@ import qualified Test.TestPico as P import qualified Test.TestPico2 as P2 import qualified Test.TestDmyHm as D +import qualified Test.TestDatePart as Dp    main::IO()@@ -18,3 +19,4 @@         P.main         D.main         P2.main+        Dp.main
+ test/Test/TestDatePart.hs view
@@ -0,0 +1,37 @@+module Test.TestDatePart where++import Test.Hspec+import Prelude hiding (until)+import Data.Time.Hora.Type.DatePart+default (Int) +++main::IO()+main = hspec $ do+       describe "Test.TestDatePart" $ do+          it "Ord" $ do+            (dp 1 1 1 1 1 1 1)  `shouldSatisfy` (== (dp 1 1 1 1 1 1 1))+            (dp 1 1 1 1 1 1 1)  `shouldSatisfy` (<= (dp 1 1 1 1 1 1 1))+            (dp 1 1 1 1 1 1 1)  `shouldSatisfy` (>= (dp 1 1 1 1 1 1 1))+            (dp 1 1 1 1 1 1 2)  `shouldSatisfy` (> (dp 1 1 1 1 1 1 1))+            (dp 1 1 1 1 1 1 1)  `shouldSatisfy` (<= (dp 1 1 1 1 1 1 2))+            (dp 2 1 1 1 1 1 1)  `shouldSatisfy` (< (dp 2 1 1 1 1 1 2))+            (dp 1 1 1 2 1 1 1)  `shouldSatisfy` (< (dp 1 1 1 3 1 1 1))+            (dp 1 1 1 1 3 1 1)  `shouldSatisfy` (> (dp 1 1 1 1 1 1 1))+          it "Ord" $ do+            now `shouldSatisfy` (< until)+            until `shouldSatisfy` (< stop)+++now::DatePart Int+now = DatePart {year = 2016, month = 12, day = 14, hour = 11, minute = 53, second = 38, pico = 413037964000}++until::DatePart Int+until = DatePart {year = 2016, month = 12, day = 14, hour = 11, minute = 55, second = 35, pico = 754503772000}++stop:: DatePart Int+stop = DatePart {year = 2016, month = 12, day = 14, hour = 11, minute = 55, second = 45, pico = 754504065000}+++dp::Int -> Int -> Int -> Int -> Int -> Int -> Int -> DatePart Int+dp = DatePart