Giter Site home page Giter Site logo

haskell-utc's People

Contributors

lpeterse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

haskell-utc's Issues

renderRfc3339 interprets offset as minutes instead of seconds

Consequently, renderRfc3339 is always off by a factor of 60:

> renderRfc3339  (Local (Just 3600) (epoch :: DateTime)) :: Maybe Text
Just "1970-01-01T00:00:00+60:00"

parseRfc3339 uses the offset correctly however, consequently renderRfc3339 and parseRfc3339 don't form an identity relationship anymore:

(parseRfc3339 "1970-01-01T00:00:00+01:00"  :: Maybe (Local DateTime)) >>= renderRfc3339) :: Maybe Text 
Just "1970-01-01T00:00:00+60:00"

renderRfc3339 and parseRfc3339 interpret datetime of RFC3339 string as UTC regardless of UTC offset

RFC3339 strings consist of a local time and an UTC offset. renderRfc3339 and parseRfc3339 however always interpret the local time of the string as utc time: Instead of offseting the utc field by offset before rendering and after parsing to convert the utc time of the Local type to the local time of the RFC3339 string and vice versa, these functions just treat RFC3339 as if it were a UTC time and an additional offset (just like Local works internally).

From RFC3339

Numeric offsets are calculated as "local time minus UTC". So the
equivalent time in UTC can be determined by subtracting the offset
from the local time. For example, 18:50:00-04:00 is the same time as
22:50:00Z. (This example shows negative offsets handled by adding
the absolute value of the offset.)

This bug is caused by not operating on the Local type, but on the internal type wrapped by Local whose IsTime and IsDate instances don't know about the offset. It is not trivial to fix, since in rfc3339Builder IsDate (Local t) IsTime (Local t) can't be deduced. It would require IsDate t and IsTime t to imply IsDate (Local t) and IsTime (Local t) which is currently not the case and might be tricky to achieve.

addSecondFractions fails if fraction -1 is added

To reproduce:

addSecondFractions (-1.0) epoch :: IO Time
*** Exception: UtcException "Time: setSecondFraction 1 % 1 00:00:00"

This happens, because with that value, frcs would be 0 in addSecondFractions, so setSecond (frcs + 1.0) fails of course.

Consider adding the package to Stackage

It would be nice if this package would be available on Stackage. Provided that everything builds with the current snapshot (master appears to do so, but v0.2.0.1 does not), doing so is as simple as submitting a pull request to fpco/stackage to add a few lines of metadata to the build constraints file. See the guide for details.

Build fails with GHC 8

Data/UTC/Class/HasUnixTime.hs:39:3: error:
• Constraint ‘Monad m’ in the type of ‘getUnixTime’
constrains only the class type variables
Use ConstrainedClassMethods to allow it
• When checking the class method:
getUnixTime :: forall (m :: * -> *).
HasUnixTime m =>
forall a. (Monad m, IsUnixTime a) => m a
In the class declaration for ‘HasUnixTime’
cabal: Leaving directory '/tmp/cabal-tmp-9305/utc-0.2.0.1'
cabal: Error: some packages failed to install:
utc-0.2.0.1 failed during the building phase. The exception was:
ExitFailure 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.