File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
lib/core/src/Cardano/Wallet/DB/Sqlite Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ import Data.Text.Encoding
8888 ( decodeUtf8 , encodeUtf8 )
8989import Data.Time.Clock.POSIX
9090 ( POSIXTime , posixSecondsToUTCTime , utcTimeToPOSIXSeconds )
91+ import Data.Time.Format
92+ ( defaultTimeLocale , formatTime , iso8601DateFormat , parseTimeM )
9193import Data.Word
9294 ( Word32 , Word64 )
9395import Data.Word.Odd
@@ -665,9 +667,16 @@ instance PersistFieldSql DerivationPrefix where
665667-- Other
666668
667669instance PersistField POSIXTime where
668- toPersistValue = PersistUTCTime . posixSecondsToUTCTime
669- fromPersistValue (PersistUTCTime utc) = Right . utcTimeToPOSIXSeconds $ utc
670- fromPersistValue _ = Left " Could not convert to unknown construtctor POSIX seconds"
670+ toPersistValue =
671+ PersistText
672+ . T. pack
673+ . formatTime defaultTimeLocale (iso8601DateFormat (Just " %H:%M:%S" ))
674+ . posixSecondsToUTCTime
675+ fromPersistValue (PersistText time) =
676+ fmap utcTimeToPOSIXSeconds $
677+ parseTimeM True defaultTimeLocale
678+ (iso8601DateFormat (Just " %H:%M:%S" )) (T. unpack time)
679+ fromPersistValue _ = Left " Could not convert to unknown constructor POSIX seconds"
671680
672681instance PersistFieldSql POSIXTime where
673- sqlType _ = sqlType (Proxy @ Word64 )
682+ sqlType _ = sqlType (Proxy @ Text )
You can’t perform that action at this time.
0 commit comments