Parse negative time
yaitskov opened this issue · comments
Hi.
UTCTime constructed by hands can have negative dates
> T.UTCTime (T.ModifiedJulianDay (-106751992)) (realToFrac (19 * 3600 + 59*60 + 5.2241920))
-290419-11-07 19:59:05.224191999994 UTC
Mean while parser cannot handle its own show result: "-290419-11-07 19:59:05.224191999994 UTC"
> tt :: T.UTCTime <- parseTimeM True T.defaultTimeLocale "%F %T" "-1-11-07 19:59:05"
*** Exception: user error (parseTimeM: no parse of "-1-11-07 19:59:05")
I get this:
Prelude Data.Time> parseTimeM True defaultTimeLocale "%F %T" "-1-11-07 19:59:05" :: IO UTCTime
-0001-11-07 19:59:05 UTC
Which version of the time library is this?
Sorry, I had to provide more info about environment.
stack ghci --package time --compiler=ghc-9.0.1
Note: No local targets specified, so a plain ghci will be started with no package hiding or package options.
You are using snapshot: lts-16.15
If you want to use package hiding and options, then you can try one of the following:
* If you want to start a different project configuration than /home/dan/.stack/global-project/stack.yaml, then you can use stack init to create a new stack.yaml
for the packages in the current directory.
* If you want to use the project configuration at /home/dan/.stack/global-project/stack.yaml, then you can add to its 'packages' field.
Configuring GHCi with the following packages:
GHCi, version 9.0.1: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/dan/.ghci
Loaded GHCi configuration from /tmp/haskell-stack-ghci/2a3bbd58/ghci-script
λ import Data.Time as T
λ
λ gg :: T.UTCTime <- parseTimeM True T.defaultTimeLocale "%F %T" "-1-11-07 19:59:05"
*** Exception: user error (parseTimeM: no parse of "-1-11-07 19:59:05")
λ
error for ghc-8.4.4 is the same.
Possibly the same as #131. Can you tell me which version of the time library (not GHC)?
lts-16.15 has time-1.9.3. I believe this has already been fixed. Can you try it with 1.11.1.2? Put time-1.11.1.2
in your extra-deps
in your stack.yaml
.
Or actually just try this:
stack ghci --package time-1.11.1.2 --compiler=ghc-9.0.1
OK, in any case I believe this is fixed.