packages feed

text-time 0.2.0 → 0.3.1

raw patch · 5 files changed

+35/−10 lines, 5 filesdep ~Cabal

Dependency ranges changed: Cabal

Files

CHANGES.md view
@@ -1,3 +1,8 @@+# Version 0.3++  * Year can have less then 4 digits++ # Version 0.2 (2016-12-14)    * ISO formatter
README.md view
@@ -3,8 +3,7 @@  # Welcome to Text Time library -This library contains fast parser and formatter for iso dates in Text.-+This library contains fast parser and formatter for iso dates between UTCTime and Text types.   ## Installation@@ -15,7 +14,6 @@ stack test ``` - # Join in!  We are happy to receive bug reports, fixes, documentation enhancements,@@ -31,4 +29,4 @@  # Redistributing -bytestring-time source code is distributed under the BSD3 License.+text-time source code is distributed under the BSD3 License.
src/Data/Text/Time/Parse.hs view
@@ -1,5 +1,6 @@--- | This code is adapted from sqlite-simple package+{-# LANGUAGE OverloadedStrings #-} +-- | This code is adapted from sqlite-simple package module Data.Text.Time.Parse     ( parseISODateTime     , parseUTCTimeOrError@@ -53,7 +54,6 @@ getDay :: A.Parser Day getDay = do     yearStr <- A.takeWhile isDigit-    when (T.length yearStr < 4) (fail "year must consist of at least 4 digits")      let year = toNum yearStr     month <- (A.char '-' *> digits "month") <|> pure 1
test-src/Data/Text/TimeSpec.hs view
@@ -1,11 +1,16 @@ {-# LANGUAGE OverloadedStrings #-} module Data.Text.TimeSpec (spec) where -import Data.Text.Time-import Test.Hspec+import Data.Text.Lazy (toStrict) import Data.Time+import Data.Time.Calendar.MonthDay+import Test.Hspec+import Test.QuickCheck +import Data.Text.Time ++ spec :: Spec spec = do @@ -14,6 +19,9 @@     it "iso format: YYYY" $ do         parseISODateTime "2014" `shouldBe` UTCTime (fromGregorian 2014 1 1) 0 +    it "iso format: YYYY" $ do+        parseISODateTime "98" `shouldBe` UTCTime (fromGregorian 98 1 1) 0+     it "iso format: YYYY-MM" $ do         parseISODateTime "2014-04" `shouldBe` UTCTime (fromGregorian 2014 4 1) 0 @@ -34,3 +42,17 @@     it "to iso" $ do         formatISODateTime (UTCTime (fromGregorian 2014 1 1) 13513) `shouldBe` "2014-01-01T03:45:13" ++  describe "Invariants" $ do++    it "is inverse to show" $ property $+        \x -> (parseISODateTime . toStrict . formatISODateTime) x == (x :: UTCTime)+++instance Arbitrary UTCTime where+  arbitrary = do+      year <- choose (0, 10^4) :: Gen Integer+      month <- choose (1, 12) :: Gen Int+      day <- choose (1, monthLength False month) :: Gen Int+      seconds <- choose (0, 86399) :: Gen Int+      return $ UTCTime (fromGregorian year month day) (realToFrac seconds)
text-time.cabal view
@@ -1,5 +1,5 @@ name:           text-time-version:        0.2.0+version:        0.3.1 synopsis:       Library for Time parsing from Text into UTCTime License:        BSD3 License-file:   LICENSE@@ -45,7 +45,7 @@                     base >= 4 && <5,                     hspec >=2 && <3,                     QuickCheck >=2.6 && <3,-                    Cabal >=1.16.0 && <2,+                    Cabal >=1.16.0 && <4,                     attoparsec < 0.14,                     formatting < 7,                     text < 2,