packages feed

nanotime 0.3.0 → 0.3.1

raw patch · 2 files changed

+19/−2 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Nanotime: showPosixTime :: PosixTime -> String
+ Nanotime: showTimeDelta :: Int -> TimeDelta -> String

Files

nanotime.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           nanotime-version:        0.3.0+version:        0.3.1 synopsis:       a tiny time library description:    Please see the README on GitHub at <https://github.com/ejconlon/nanotime#readme> homepage:       https://github.com/ejconlon/nanotime#readme
src/Nanotime.hs view
@@ -6,9 +6,11 @@   , timeDeltaToFracSecs   , timeDeltaToNanos   , threadDelayDelta+  , showTimeDelta   , TimeLike (..)   , awaitDelta   , PosixTime (..)+  , showPosixTime   , MonoTime (..)   , monoTimeToFracSecs   , monoTimeToNanos@@ -23,11 +25,14 @@ import Control.Concurrent (threadDelay) import Data.Bits (Bits (..)) import Data.Fixed (Fixed (..), Pico)+import Data.Ratio ((%)) import Data.Time.Clock (nominalDiffTimeToSeconds)-import Data.Time.Clock.POSIX (getPOSIXTime)+import Data.Time.Clock.POSIX (getPOSIXTime, posixSecondsToUTCTime)+import Data.Time.Format.ISO8601 (iso8601Show) import Data.Word (Word32, Word64) import GHC.Clock (getMonotonicTimeNSec) import GHC.Stack (HasCallStack)+import Numeric (showFFloat)  -- | Sign (negative or positive) of a magnitude of time difference data Sign = SignNeg | SignPos@@ -148,6 +153,12 @@     SignPos | m > 0 -> threadDelay (fromIntegral (div m 1000))     _ -> pure () +-- | Show a 'TimeDelta' as a fractional second with the given number+-- of decimal places for debugging+showTimeDelta :: Int -> TimeDelta -> String+showTimeDelta places td = showFFloat @Double (Just places) (timeDeltaToFracSecs td) ""++-- | 'MonoTime', 'PosixTime', and 'NtpTime' act similarly class (Ord t) => TimeLike t where   -- | `diffTime end start` computes `end - start`   diffTime :: t -> t -> TimeDelta@@ -155,6 +166,7 @@   -- | `addTime start (diffTime end start) == end`   addTime :: t -> TimeDelta -> t +  -- | Get the current time in the desired type   currentTime :: IO t  awaitDelta :: (TimeLike t) => t -> TimeDelta -> IO t@@ -166,6 +178,11 @@  newtype PosixTime = PosixTime {unPosixTime :: Word64}   deriving stock (Eq, Show, Ord, Bounded)++-- | Show 'PosixTime' as a UTC ISO-8601 String for debugging+showPosixTime :: PosixTime -> String+showPosixTime (PosixTime ns) =+  iso8601Show (posixSecondsToUTCTime (fromRational (fromIntegral ns % 1000000000)))  -- private e9W :: Word64