packages feed

datetime-sb 0.2.2 → 0.2.3

raw patch · 3 files changed

+41/−28 lines, 3 filesdep +HUnitdep +datetime-sbdep +test-frameworkdep ~QuickCheckdep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: HUnit, datetime-sb, test-framework, test-framework-hunit, test-framework-quickcheck2

Dependency ranges changed: QuickCheck, base

API changes (from Hackage documentation)

- Data.DateTime: instance Arbitrary UTCTime
- Data.DateTime: invariant :: Eq a => (a -> a) -> a -> Bool
- Data.DateTime: prop_MJD :: DateTime -> Bool
- Data.DateTime: prop_MJD' :: DateTime -> Bool
- Data.DateTime: prop_SqlStartOfTime :: t -> Bool
- Data.DateTime: prop_SqlString :: DateTime -> Bool
- Data.DateTime: prop_StartOfTime :: t -> Bool
- Data.DateTime: prop_Universal :: DateTime -> Bool

Files

datetime-sb.cabal view
@@ -1,5 +1,5 @@ name:                datetime-sb-version:             0.2.2+version:             0.2.3 stability:           experimental Description:   Provides several utilities for easily converting among the@@ -12,15 +12,41 @@ homepage:            http://github.com/stackbuilders/datetime category:            Data synopsis:            Utilities to make Data.Time.* easier to use.-cabal-version:       >= 1.2+cabal-version:       >= 1.10 build-type:          Simple +source-repository head+  type:            git+  location:        https://github.com/stackbuilders/datetime.git+ library   build-depends:     base < 5,-                     QuickCheck >= 2 && < 3,                      old-locale >= 1.0.0.1,                      old-time >= 1.0.0.1,                      time >= 1.1.2.2-  extensions:       CPP+  default-extensions:       CPP   exposed-modules:   Data.DateTime   hs-source-dirs:    src+  ghc-options:         -Wall+  default-language:    Haskell2010++test-suite test+  type: exitcode-stdio-1.0+  hs-source-dirs: test+  main-is: Suite.hs+  build-depends:+      datetime-sb++      , old-locale >= 1.0.0.1+      , old-time >= 1.0.0.1+      , time >= 1.1.2.2++      , base >=4.2 && <4.9+      , test-framework+      , HUnit+      , QuickCheck+      , test-framework-hunit+      , test-framework-quickcheck2++  ghc-options:         -Wall+  default-language:    Haskell2010
src/Data/DateTime.hs view
@@ -4,8 +4,7 @@  import Data.Fixed (div') import Data.Function (on)-import Data.Maybe (fromJust)-import Data.Time.Calendar hiding (fromGregorian, toGregorian)+ import Data.Time.Clock hiding (getCurrentTime) import Data.Time.Format import Data.Time.LocalTime@@ -16,7 +15,6 @@ #endif  import System.Time hiding (toClockTime)-import Test.QuickCheck  import qualified Data.Time.Calendar as Calendar import qualified Data.Time.Clock as Clock@@ -26,11 +24,6 @@  type DateTime = UTCTime -instance Arbitrary UTCTime where-    arbitrary       = do-        offset <- choose (0, 20000) :: Gen Float-        return . fromMJD' $ offset + fromRational startOfTimeMJD- -- Defined here so that users don't need to know about Data.Time.Clock.  getCurrentTime :: IO DateTime@@ -50,11 +43,6 @@ fromMJD' :: RealFloat a => a -> DateTime fromMJD' = fromMJD . realToFrac -invariant f x = f x == x--prop_MJD  = invariant $ fromMJD  . toMJD-prop_MJD' = invariant $ fromMJD' . toMJD'- -- Because UTCTime is opaque, we need to convert to UniversalTime in -- order to do anything with it, but these functions are mainly of -- interest internally.@@ -65,8 +53,6 @@ fromUniversalTime :: UniversalTime -> DateTime fromUniversalTime = localTimeToUTC utc . ut1ToLocalTime 0 -prop_Universal = invariant $ fromUniversalTime . toUniversalTime- -- Take apart a DateTime into pieces and parts.  toGregorian'    :: DateTime -> (Integer, Int, Int)@@ -99,7 +85,7 @@  toSeconds    :: DateTime -> Integer toSeconds dt = floor $-    86400.0 * fromRational (toMJD dt - startOfTimeMJD)+    (86400.0 :: Double) * fromRational (toMJD dt - startOfTimeMJD)  fromSeconds   :: Integer -> DateTime fromSeconds s = fromMJD $@@ -114,8 +100,6 @@ startOfTime :: DateTime startOfTime = fromGregorian' 1970 1 1 -prop_StartOfTime _ = toSeconds startOfTime == 0- startOfTimeMJD :: Rational startOfTimeMJD = toMJD startOfTime @@ -128,18 +112,13 @@ fromSqlString :: String -> Maybe DateTime fromSqlString = parseDateTime sqlFormat -prop_SqlString dt = (fromJust . fromSqlString . toSqlString $ dt') == dt'-  where-    Just dt' = fromSqlString . toSqlString $ dt--prop_SqlStartOfTime _ = toSqlString startOfTime == "1970-01-01 00:00:00"- formatDateTime :: String -> DateTime -> String formatDateTime = formatTime defaultTimeLocale  parseDateTime :: String -> String -> Maybe DateTime parseDateTime = parseTime defaultTimeLocale +sqlFormat :: String sqlFormat = iso8601DateFormat (Just "%T")  -- Simple arithmetic.
+ test/Suite.hs view
@@ -0,0 +1,8 @@+module Main where++import  Test.Framework (defaultMain)++import qualified Data.DateTimeTest++main :: IO ()+main = defaultMain $ Data.DateTimeTest.tests