chronos 1.1.5.1 → 1.1.6.0
raw patch · 3 files changed
+38/−12 lines, 3 filesdep ~basedep ~bytebuilddep ~bytestringPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, bytebuild, bytestring, text
API changes (from Hackage documentation)
+ Chronos: asSeconds :: Timespan -> Int64
+ Chronos: sinceEpoch :: Time -> Timespan
Files
- chronos.cabal +7/−6
- src/Chronos.hs +28/−6
- src/Chronos/Internal/CTimespec.hs +3/−0
chronos.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: chronos-version: 1.1.5.1+version: 1.1.6.0 synopsis: A high-performance time library description: Chronos is a performance-oriented time library for Haskell, with a@@ -35,6 +35,7 @@ copyright: 2016 Andrew Martin category: Data, Time, Parsing, Development build-type: Simple+tested-with: GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.4 || ==9.8.1 library hs-source-dirs: src@@ -46,18 +47,18 @@ -- it is OPTIONS_HADDOCK-hidden Chronos.Internal.CTimespec build-depends:- , aeson >= 1.1 && < 2.2+ , aeson >= 1.1 && < 2.3 , attoparsec >= 0.13 && < 0.15- , base >= 4.14 && < 4.19- , bytestring >= 0.10 && < 0.12+ , base >= 4.14 && < 4.20+ , bytestring >= 0.10 && < 0.13 , deepseq >= 1.4.4.0 , hashable >= 1.2 && < 1.5 , primitive >= 0.6.4 && < 0.10 , semigroups >= 0.16 && < 0.21- , text >= 1.2 && < 1.3 || >= 2.0 && < 2.1+ , text >= 1.2 && < 1.3 || >= 2.0 && < 2.2 , torsor >= 0.1 && < 0.2 , vector >= 0.11 && < 0.14- , bytebuild >= 0.3.8 && < 0.4+ , bytebuild >= 0.3.16 && < 0.4 , bytesmith >= 0.3.7 && < 0.4 , byteslice >= 0.2.5.2 && <0.3 , text-short >= 0.1.3 && <0.2
src/Chronos.hs view
@@ -1,5 +1,6 @@ {-# language BangPatterns #-} {-# language CPP #-}+{-# language DataKinds #-} {-# language DeriveGeneric #-} {-# language GeneralizedNewtypeDeriving #-} {-# language LambdaCase #-}@@ -11,7 +12,6 @@ {-# language ScopedTypeVariables #-} {-# language TypeApplications #-} {-# language TypeFamilies #-}-{-# language TypeInType #-} {-# language UnboxedTuples #-} {-| Chronos is a performance-oriented time library for Haskell, with a@@ -116,6 +116,9 @@ , daysInMonth , isLeapYear , observedOffsets+ , sinceEpoch+ , asSeconds+ -- * Textual Conversion -- ** Date -- *** Text@@ -727,6 +730,19 @@ , 1400 ] +-- | Compute the 'Timespan' between the given date and 'epoch'.+--+-- @since 1.1.6.0+sinceEpoch :: Time -> Timespan+sinceEpoch t = difference t epoch++-- | Convert a 'Timespan' to its equivalent in seconds.+--+-- @since 1.1.6.0+asSeconds :: Timespan -> Int64+asSeconds (Timespan t) = case second of+ Timespan s -> t `div` s+ -- | The first argument in the resulting tuple in a day -- adjustment. It should be either -1, 0, or 1, as no -- offset should ever exceed 24 hours.@@ -3516,7 +3532,7 @@ -- Examples of output: -- -- > 2021-01-05T23:00:51--- > 2021-01-05T23:00:52.123000000+-- > 2021-01-05T23:00:52.123 -- > 2021-01-05T23:00:53.674094347 boundedBuilderUtf8BytesIso8601Zoneless :: Datetime -> Bounded.Builder 44 boundedBuilderUtf8BytesIso8601Zoneless (Datetime (Date (Year y) (Month mth) (DayOfMonth d)) (TimeOfDay h mt sns)) =@@ -3545,10 +3561,16 @@ `Bounded.append` (case ns of 0 -> Bounded.weaken @0 @10 Lte.constant Bounded.empty- _ ->- Bounded.ascii '.'- `Bounded.append`- Bounded.wordPaddedDec9 (fromIntegral ns)+ _ -> let (ms,us) = quotRem ns 1_000_000 in case us of+ 0 -> Bounded.weaken @4 @10 Lte.constant+ ( Bounded.ascii '.'+ `Bounded.append`+ Bounded.wordPaddedDec3 (fromIntegral ms)+ )+ _ ->+ Bounded.ascii '.'+ `Bounded.append`+ Bounded.wordPaddedDec9 (fromIntegral ns) ) boundedBuilderOffset :: Offset -> Bounded.Builder 6
src/Chronos/Internal/CTimespec.hs view
@@ -1,5 +1,8 @@ {-# LANGUAGE CPP #-}++#if defined(ghcjs_HOST_OS) {-# LANGUAGE JavaScriptFFI #-}+#endif {-# OPTIONS_HADDOCK hide #-} -- for doctests