[commit: packages/time] master, wip/travis: Added diffTimeToPicoseconds (also cleaned up picosecondsToDiffTime) (020ce40)
git at git.haskell.org
git at git.haskell.org
Sat May 7 06:50:31 UTC 2016
Repository : ssh://git@git.haskell.org/time
On branches: master,wip/travis
Link : http://git.haskell.org/packages/time.git/commitdiff/020ce40e69951849041349c0c38243e56169f572
>---------------------------------------------------------------
commit 020ce40e69951849041349c0c38243e56169f572
Author: Ashley Yakeley <ashley at yakeley.org>
Date: Sat May 30 21:54:25 2015 -0700
Added diffTimeToPicoseconds (also cleaned up picosecondsToDiffTime)
>---------------------------------------------------------------
020ce40e69951849041349c0c38243e56169f572
lib/Data/Time/Clock/Scale.hs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/Data/Time/Clock/Scale.hs b/lib/Data/Time/Clock/Scale.hs
index 5838b4d..c508f7b 100644
--- a/lib/Data/Time/Clock/Scale.hs
+++ b/lib/Data/Time/Clock/Scale.hs
@@ -10,7 +10,9 @@ module Data.Time.Clock.Scale
-- * Absolute intervals
DiffTime,
- secondsToDiffTime, picosecondsToDiffTime
+ secondsToDiffTime,
+ picosecondsToDiffTime,
+ diffTimeToPicoseconds,
) where
import Control.DeepSeq
@@ -101,7 +103,11 @@ secondsToDiffTime = fromInteger
-- | Create a 'DiffTime' from a number of picoseconds.
picosecondsToDiffTime :: Integer -> DiffTime
-picosecondsToDiffTime x = fromRational (x % 1000000000000)
+picosecondsToDiffTime x = MkDiffTime (MkFixed x)
+
+-- | Get the number of picoseconds in a 'DiffTime'.
+diffTimeToPicoseconds :: DiffTime -> Integer
+diffTimeToPicoseconds (MkDiffTime (MkFixed x)) = x
{-# RULES
"realToFrac/DiffTime->Pico" realToFrac = \ (MkDiffTime ps) -> ps
More information about the ghc-commits
mailing list