Skip to content

Commit

Permalink
Add function nominalDiffTimeToMicroseconds.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Aug 3, 2020
1 parent d51b74d commit d0b454b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/core/src/Data/Time/Utils.hs
@@ -1,18 +1,27 @@
{-# LANGUAGE NumericUnderscores #-}

-- |
-- Copyright: © 2018-2020 IOHK
-- License: Apache-2.0
--
-- Utility functions for manipulating time values.

module Data.Time.Utils
( utcTimePred
( nominalDiffTimeToMicroseconds
, utcTimePred
, utcTimeSucc
) where

import Prelude

import Data.Time
( UTCTime, addUTCTime )
( NominalDiffTime, UTCTime, addUTCTime )

-- | Converts the specified time difference into an integral number of
-- microseconds.
--
nominalDiffTimeToMicroseconds :: Integral i => NominalDiffTime -> i
nominalDiffTimeToMicroseconds = ceiling . (* 1_000_000) . toRational

-- | For a given time 't0', get the closest representable time 't1' to 't0'
-- for which 't0 < t1'.
Expand Down

0 comments on commit d0b454b

Please sign in to comment.