packages feed

persistent 2.1.1.2 → 2.1.1.3

raw patch · 3 files changed

+20/−3 lines, 3 filesdep +old-locale

Dependencies added: old-locale

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 2.1.1.3++Parse UTCTime in 8601 format [#339](https://github.com/yesodweb/persistent/issues/339)+ ## 2.1.1.1  Support for monad-control 1.0
Database/Persist/Class/PersistField.hs view
@@ -15,7 +15,7 @@     ) where  import Database.Persist.Types.Base-import Data.Time (Day(..), TimeOfDay, UTCTime)+import Data.Time (Day(..), TimeOfDay, UTCTime, parseTime) #ifdef HIGH_PRECISION_DATE import Data.Time.Clock.POSIX (posixSecondsToUTCTime) #endif@@ -48,6 +48,12 @@ import qualified Data.Text.Encoding as TE import qualified Data.Vector as V +#if MIN_VERSION_time(1,5,0)+import Data.Time (defaultTimeLocale)+#else+import System.Locale (defaultTimeLocale)+#endif+ -- | A value which can be marshalled to and from a 'PersistValue'. class PersistField a where     toPersistValue :: a -> PersistValue@@ -221,7 +227,12 @@     fromPersistValue x@(PersistText t)  =         case reads $ T.unpack t of             (d, _):_ -> Right d-            _ -> Left $ T.pack $ "Expected UTCTime, received " ++ show x+            _ ->+                case parse8601 $ T.unpack t of+                    Nothing -> Left $ T.pack $ "Expected UTCTime, received " ++ show x+                    Just x -> Right x+      where+        parse8601 = parseTime defaultTimeLocale "%FT%T%Q"     fromPersistValue x@(PersistByteString s) =         case reads $ unpack s of             (d, _):_ -> Right d
persistent.cabal view
@@ -1,5 +1,5 @@ name:            persistent-version:         2.1.1.2+version:         2.1.1.3 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -26,6 +26,7 @@                    , bytestring               >= 0.9                    , transformers             >= 0.2.1                    , time                     >= 1.1.4+                   , old-locale                    , text                     >= 0.8                    , containers               >= 0.2                    , conduit                  >= 1.0@@ -90,6 +91,7 @@                    , text                    , unordered-containers                    , time+                   , old-locale                    , bytestring                    , vector                    , base64-bytestring