cdornan / enum-text Goto Github PK
View Code? Open in Web Editor NEWA text rendering and parsing toolkit for enumerated types
License: BSD 3-Clause "New" or "Revised" License
A text rendering and parsing toolkit for enumerated types
License: BSD 3-Clause "New" or "Revised" License
Given this program:
{-# LANGUAGE TypeApplications #-}
module TestUTC where
import Data.Time
import Text.Read
main :: IO ()
main = print @(Maybe UTCTime) $ readMaybe "2020-01-01 10:12:30"
The parsing of this UTCTime
differs from time time-1.8.0.2
and time-1.9.3
:
stack --resolver lts-14.10 --no-system-ghc exec runghc -- TestUTC.hs
Just 2020-01-01 10:12:30 UTC
stack --resolver lts-17.5 --no-system-ghc exec runghc -- TestUTC.hs
Nothing
I haven't investigated exactly what change in time
triggered it (possibly the handling of a ZonedTime
) but the current instance TextParsable UTCTime
behaves differently between time
versions.
As discussed with @adamgundry, possibly the easiest fix would be cribbing the parseUTC from api-tools
and use it here, as it does the right thing. Compare:
{-# LANGUAGE TypeApplications #-}
module TestUTC where
import Data.Time
import qualified Data.API.Time as API
import qualified Data.Text as T
import Text.Read
main :: IO ()
main = do
print @(Maybe UTCTime) $ readMaybe "2020-01-01 10:12:30"
print @(Maybe UTCTime) $ API.parseUTC (T.pack "2020-01-01 10:12:30")
It yields:
stack --resolver lts-14.10 --no-system-ghc exec --package api-tools-0.9.0.0 runghc -- TestUTC.hs
Just 2020-01-01 10:12:30 UTC
Just 2020-01-01 10:12:30 UTC
stack --resolver lts-17.15 --no-system-ghc exec --package api-tools-0.9.0.0 runghc -- TestUTC.hs
Nothing
Just 2020-01-01 10:12:30 UTC
Preprocessing library for enum-text-0.5.3.0..
Building library for enum-text-0.5.3.0..
Preprocessing test suite 'enum-text-tests' for enum-text-0.5.3.0..
Building test suite 'enum-text-tests' for enum-text-0.5.3.0..
doctest-discover: test/doctest-config.json: openFile: does not exist (No such file or directory)
/var/stackage/work/unpack-dir/unpacked/enum-text-0.5.3.0-ad5b97504fac04b18c6704c259c0c3d6a60c86bee0ffab92ec2d27d28a3514ce/tes
t/Doctest.hs:1:1: error:
`doctest-discover' failed in phase `Haskell pre-processor'. (Exit code: 1)
|
1 | {-# OPTIONS_GHC -F -pgmF doctest-discover -optF test/doctest-config.json #-}
| ^
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.