Hello community, here is the log from the commit of package ghc-http-api-data for openSUSE:Factory checked in at 2015-12-23 08:49:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-http-api-data (Old) and /work/SRC/openSUSE:Factory/.ghc-http-api-data.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-http-api-data" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-http-api-data/ghc-http-api-data.changes 2015-11-26 17:03:47.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-http-api-data.new/ghc-http-api-data.changes 2015-12-23 08:49:20.000000000 +0100 @@ -1,0 +2,6 @@ +Sun Dec 13 16:38:11 UTC 2015 - mimi...@gmail.com + +- update to 0.2.2 +* Add instances for more time types: LocalTime, ZonedTime, UTCTime and NominalDiffTime + +------------------------------------------------------------------- Old: ---- http-api-data-0.2.1.tar.gz New: ---- http-api-data-0.2.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-http-api-data.spec ++++++ --- /var/tmp/diff_new_pack.NKfQjk/_old 2015-12-23 08:49:21.000000000 +0100 +++ /var/tmp/diff_new_pack.NKfQjk/_new 2015-12-23 08:49:21.000000000 +0100 @@ -21,7 +21,7 @@ %bcond_with tests Name: ghc-http-api-data -Version: 0.2.1 +Version: 0.2.2 Release: 0 Summary: Converting to/from HTTP API data like URL pieces, headers and query parameters License: BSD-2-Clause @@ -37,6 +37,7 @@ BuildRequires: ghc-bytestring-devel BuildRequires: ghc-text-devel BuildRequires: ghc-time-devel +BuildRequires: ghc-time-locale-compat-devel %if %{with tests} BuildRequires: ghc-Glob-devel BuildRequires: ghc-HUnit-devel ++++++ http-api-data-0.2.1.tar.gz -> http-api-data-0.2.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/http-api-data-0.2.1/CHANGELOG.md new/http-api-data-0.2.2/CHANGELOG.md --- old/http-api-data-0.2.1/CHANGELOG.md 2015-10-12 18:00:56.000000000 +0200 +++ new/http-api-data-0.2.2/CHANGELOG.md 2015-12-10 11:34:51.000000000 +0100 @@ -1,3 +1,8 @@ +0.2.2 +--- + +* Add instances for more `time` types: `LocalTime`, `ZonedTime`, `UTCTime` and `NominalDiffTime` + 0.2.1 --- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/http-api-data-0.2.1/Web/HttpApiData/Internal.hs new/http-api-data-0.2.2/Web/HttpApiData/Internal.hs --- old/http-api-data-0.2.1/Web/HttpApiData/Internal.hs 2015-10-12 18:00:09.000000000 +0200 +++ new/http-api-data-0.2.2/Web/HttpApiData/Internal.hs 2015-12-10 11:08:55.000000000 +0100 @@ -28,6 +28,7 @@ import qualified Data.Text as T import qualified Data.Text.Lazy as L +import Data.Time.Locale.Compat import Data.Time import Data.Version @@ -364,6 +365,26 @@ -- "2015-10-03" instance ToHttpApiData Day where toUrlPiece = T.pack . show +timeToUrlPiece :: FormatTime t => String -> t -> Text +timeToUrlPiece fmt = T.pack . formatTime defaultTimeLocale (iso8601DateFormat (Just fmt)) + +-- | +-- >>> toUrlPiece $ LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 01) +-- "2015-10-03T14:55:01" +instance ToHttpApiData LocalTime where toUrlPiece = timeToUrlPiece "%H:%M:%S" + +-- | +-- >>> toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 01)) utc +-- "2015-10-03T14:55:01+0000" +instance ToHttpApiData ZonedTime where toUrlPiece = timeToUrlPiece "%H:%M:%S%z" + +-- | +-- >>> toUrlPiece $ UTCTime (fromGregorian 2015 10 03) 864 +-- "2015-10-03T00:14:24Z" +instance ToHttpApiData UTCTime where toUrlPiece = timeToUrlPiece "%H:%M:%SZ" + +instance ToHttpApiData NominalDiffTime where toUrlPiece = toUrlPiece . (floor :: NominalDiffTime -> Integer) + instance ToHttpApiData String where toUrlPiece = T.pack instance ToHttpApiData Text where toUrlPiece = id instance ToHttpApiData L.Text where toUrlPiece = L.toStrict @@ -445,6 +466,28 @@ -- Right (2016,12,1) instance FromHttpApiData Day where parseUrlPiece = readTextData +timeParseUrlPiece :: ParseTime t => String -> Text -> Either Text t +timeParseUrlPiece fmt = parseMaybeTextData (timeParseUrlPieceMaybe . T.unpack) + where + timeParseUrlPieceMaybe = parseTime defaultTimeLocale (iso8601DateFormat (Just fmt)) + +-- | +-- >>> parseUrlPiece "2015-10-03T14:55:01" :: Either Text LocalTime +-- Right 2015-10-03 14:55:01 +instance FromHttpApiData LocalTime where parseUrlPiece = timeParseUrlPiece "%H:%M:%S" + +-- | +-- >>> parseUrlPiece "2015-10-03T14:55:01+0000" :: Either Text ZonedTime +-- Right 2015-10-03 14:55:01 +0000 +instance FromHttpApiData ZonedTime where parseUrlPiece = timeParseUrlPiece "%H:%M:%S%z" + +-- | +-- >>> parseUrlPiece "2015-10-03T00:14:24Z" :: Either Text UTCTime +-- Right 2015-10-03 00:14:24 UTC +instance FromHttpApiData UTCTime where parseUrlPiece = timeParseUrlPiece "%H:%M:%SZ" + +instance FromHttpApiData NominalDiffTime where parseUrlPiece = fmap fromInteger . parseUrlPiece + instance FromHttpApiData All where parseUrlPiece = fmap All . parseUrlPiece instance FromHttpApiData Any where parseUrlPiece = fmap Any . parseUrlPiece diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/http-api-data-0.2.1/http-api-data.cabal new/http-api-data-0.2.2/http-api-data.cabal --- old/http-api-data-0.2.1/http-api-data.cabal 2015-10-12 18:01:00.000000000 +0200 +++ new/http-api-data-0.2.2/http-api-data.cabal 2015-12-10 11:34:51.000000000 +0100 @@ -1,5 +1,5 @@ name: http-api-data -version: 0.2.1 +version: 0.2.2 license: BSD3 license-file: LICENSE author: Nickolay Kudasov <nickolay.kuda...@gmail.com> @@ -25,6 +25,7 @@ , text >= 0.5 , bytestring , time + , time-locale-compat if flag(use-text-show) cpp-options: -DUSE_TEXT_SHOW build-depends: text-show >= 2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/http-api-data-0.2.1/test/Spec.hs new/http-api-data-0.2.2/test/Spec.hs --- old/http-api-data-0.2.1/test/Spec.hs 2015-10-11 23:22:19.000000000 +0200 +++ new/http-api-data-0.2.2/test/Spec.hs 2015-12-10 11:08:55.000000000 +0100 @@ -27,6 +27,25 @@ instance Arbitrary Day where arbitrary = liftA3 fromGregorian (fmap abs arbitrary) arbitrary arbitrary +instance Arbitrary LocalTime where + arbitrary = LocalTime + <$> arbitrary + <*> liftA3 TimeOfDay (choose (0, 23)) (choose (0, 59)) (fromInteger <$> choose (0, 60)) + +instance Eq ZonedTime where + ZonedTime t (TimeZone x _ _) == ZonedTime t' (TimeZone y _ _) = t == t' && x == y + +instance Arbitrary ZonedTime where + arbitrary = ZonedTime + <$> arbitrary + <*> liftA3 TimeZone arbitrary arbitrary (vectorOf 3 (elements ['A'..'Z'])) + +instance Arbitrary UTCTime where + arbitrary = UTCTime <$> arbitrary <*> fmap fromInteger (choose (0, 86400)) + +instance Arbitrary NominalDiffTime where + arbitrary = fromInteger <$> arbitrary + instance Arbitrary Version where arbitrary = (version . map abs) <$> nonempty where @@ -89,6 +108,10 @@ checkUrlPiece (Proxy :: Proxy T.Text) "Text.Strict" checkUrlPiece (Proxy :: Proxy L.Text) "Text.Lazy" checkUrlPiece (Proxy :: Proxy Day) "Day" + checkUrlPiece (Proxy :: Proxy LocalTime) "LocalTime" + checkUrlPiece (Proxy :: Proxy ZonedTime) "ZonedTime" + checkUrlPiece (Proxy :: Proxy UTCTime) "UTCTime" + checkUrlPiece (Proxy :: Proxy NominalDiffTime) "NominalDiffTime" checkUrlPiece (Proxy :: Proxy Version) "Version" checkUrlPiece (Proxy :: Proxy (Maybe String)) "Maybe String"