chronos 0.3 → 0.4
raw patch · 4 files changed
+55/−19 lines, 4 filesdep ~aesondep ~vectorPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, vector
API changes (from Hackage documentation)
- Chronos.Types: instance Data.Aeson.Types.Class.FromJSON Chronos.Types.Nanoseconds
- Chronos.Types: instance Data.Aeson.Types.Class.FromJSON Chronos.Types.PosixTime
- Chronos.Types: instance Data.Aeson.Types.Class.FromJSON Chronos.Types.TaiTime
- Chronos.Types: instance Data.Aeson.Types.Class.ToJSON Chronos.Types.Nanoseconds
- Chronos.Types: instance Data.Aeson.Types.Class.ToJSON Chronos.Types.PosixTime
- Chronos.Types: instance Data.Aeson.Types.Class.ToJSON Chronos.Types.TaiTime
- Chronos.Types: instance GHC.Generics.Constructor Chronos.Types.C1_0OffsetFormat
- Chronos.Types: instance GHC.Generics.Constructor Chronos.Types.C1_1OffsetFormat
- Chronos.Types: instance GHC.Generics.Constructor Chronos.Types.C1_2OffsetFormat
- Chronos.Types: instance GHC.Generics.Constructor Chronos.Types.C1_3OffsetFormat
- Chronos.Types: instance GHC.Generics.Datatype Chronos.Types.D1OffsetFormat
+ Chronos.Day: fromDate :: Date -> Day
+ Chronos.Day: toDate :: Day -> Date
+ Chronos.Posix: fromDay :: Day -> PosixTime
+ Chronos.Types: instance Data.Aeson.Types.FromJSON.FromJSON Chronos.Types.Day
+ Chronos.Types: instance Data.Aeson.Types.FromJSON.FromJSON Chronos.Types.Nanoseconds
+ Chronos.Types: instance Data.Aeson.Types.FromJSON.FromJSON Chronos.Types.PosixTime
+ Chronos.Types: instance Data.Aeson.Types.FromJSON.FromJSON Chronos.Types.TaiTime
+ Chronos.Types: instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Types.Day
+ Chronos.Types: instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Types.Nanoseconds
+ Chronos.Types: instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Types.PosixTime
+ Chronos.Types: instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Types.TaiTime
Files
- chronos.cabal +36/−13
- src/Chronos/Day.hs +8/−0
- src/Chronos/Posix.hs +6/−1
- src/Chronos/Types.hs +5/−5
chronos.cabal view
@@ -1,7 +1,29 @@ name: chronos-version: 0.3-synopsis: A time library, encoding, decoding, and instances-description: Please see README.md+version: 0.4+synopsis: A performant time library+description:+ Performance-oriented time library for haskell. The main differences+ between this and "time" are that this library:+ .+ * Uses machine integers where possible. This means that some time-related+ arithmetic should be faster. It also means that the types are incapable+ of representing times that are very far in the future or the past.+ .+ * Provides "ToJSON" and "FromJSON" instances for json serialization.+ .+ * Provides "Unbox" instances for working with unboxed vectors.+ .+ * Uses normal non-overloaded haskell functions for encoding and decoding time. It provides+ "attoparsec" parsers for both "Text" and "ByteString". Additionally, it+ provides functions for encoding time as "Text" or "ByteString". The "time"+ library uses accomplishes these with the "Data.Time.Format" module,+ which uses UNIX-style datetime format strings. It is expected that+ the approach taken in this library is faster and catches more mistakes+ at compile time at the cost of being less expressive.+ .+ * Only provides nanosecond resolution instead of picosecond resolution.++ homepage: https://github.com/andrewthad/chronos#readme license: BSD3 license-file: LICENSE@@ -10,7 +32,6 @@ copyright: 2016 Andrew Martin category: web build-type: Simple--- extra-source-files: cabal-version: >=1.10 library@@ -38,16 +59,18 @@ , Chronos.Posix , Chronos.Month , Chronos.Locale.English.Text- -- , Chronos.Calendar.Text build-depends:- base >= 4.7 && < 5- , vector- , text- , bytestring- , attoparsec- , aeson- , hashable- , primitive+ base >= 4.8 && < 5+ , vector >= 0.11 && < 0.13+ , text >= 1.2 && < 1.3+ , bytestring >= 0.10 && < 0.11+ , attoparsec >= 0.13 && < 0.14+ -- Remove support for aeson < 1.0 after the newer+ -- aeson lands in stackage. Currently, ToJSONKey+ -- and FromJSONKey instances cannot be added.+ , aeson >= 0.11 && < 1.1+ , hashable >= 1.2 && < 1.3+ , primitive >= 0.6 && < 0.7 default-language: Haskell2010 test-suite chronos-test
src/Chronos/Day.hs view
@@ -4,6 +4,8 @@ , today , tomorrow , yesterday+ , toDate+ , fromDate ) where import Chronos.Types@@ -30,4 +32,10 @@ yesterday :: IO Day yesterday = fmap (add (-1) . Posix.truncateToDay) Posix.now++fromDate :: Date -> Day+fromDate = Conv.dateToDay++toDate :: Day -> Date+toDate = Conv.dayToDate
src/Chronos/Posix.hs view
@@ -14,6 +14,7 @@ , fromDatetime , fromOffsetDatetime , truncateToDay+ , fromDay ) where import Chronos.Types@@ -69,7 +70,11 @@ fromOffsetDatetime = fromUtc . Conv.offsetDatetimeToUtcTime truncateToDay :: PosixTime -> Day-truncateToDay (PosixTime i) = Day (fromIntegral (div i 86400000000000))+truncateToDay (PosixTime i) = Day (fromIntegral (div i 86400000000000) + 40587)++-- | The 'PosixTime' at midnight on the given day.+fromDay :: Day -> PosixTime+fromDay (Day d) = PosixTime (fromIntegral (d - 40587) * 86400000000000) -- | Convert a 'PosixTime' to a UTC 'Datetime'. -- toDatetime :: PosixTime -> Datetime
src/Chronos/Types.hs view
@@ -70,15 +70,15 @@ import Data.Primitive import Control.Monad import GHC.Generics (Generic)-import qualified Data.Vector.Generic as GVector-import qualified Data.Vector.Unboxed as UVector-import qualified Data.Vector.Primitive as PVector-import qualified Data.Vector.Generic.Mutable as MGVector+import qualified Data.Vector.Generic as GVector+import qualified Data.Vector.Unboxed as UVector+import qualified Data.Vector.Primitive as PVector+import qualified Data.Vector.Generic.Mutable as MGVector -- | A day represented as the modified Julian date, the number of days -- since midnight on November 17, 1858. newtype Day = Day { getDay :: Int }- deriving (Show,Read,Eq,Ord,Hashable,Enum)+ deriving (Show,Read,Eq,Ord,Hashable,Enum,ToJSON,FromJSON) -- | The day of the week. newtype DayOfWeek = DayOfWeek { getDayOfWeek :: Int }