module ForSyDe.Atom.MoC.TimeStamp where
import Data.Time.Clock ( DiffTime
, secondsToDiffTime
, picosecondsToDiffTime
)
type TimeStamp = DiffTime
picosec :: Integer -> TimeStamp
picosec :: Integer -> TimeStamp
picosec = Integer -> TimeStamp
picosecondsToDiffTime
nanosec :: Integer -> TimeStamp
nanosec :: Integer -> TimeStamp
nanosec = Integer -> TimeStamp
picosecondsToDiffTime (Integer -> TimeStamp)
-> (Integer -> Integer) -> Integer -> TimeStamp
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
*1000)
microsec :: Integer -> TimeStamp
microsec :: Integer -> TimeStamp
microsec = Integer -> TimeStamp
picosecondsToDiffTime (Integer -> TimeStamp)
-> (Integer -> Integer) -> Integer -> TimeStamp
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
*1000000)
milisec :: Integer -> TimeStamp
milisec :: Integer -> TimeStamp
milisec = Integer -> TimeStamp
picosecondsToDiffTime (Integer -> TimeStamp)
-> (Integer -> Integer) -> Integer -> TimeStamp
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
*1000000000)
sec :: Integer -> TimeStamp
sec :: Integer -> TimeStamp
sec = Integer -> TimeStamp
secondsToDiffTime
minutes :: Integer -> TimeStamp
minutes :: Integer -> TimeStamp
minutes = Integer -> TimeStamp
secondsToDiffTime (Integer -> TimeStamp)
-> (Integer -> Integer) -> Integer -> TimeStamp
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
*60)
hours :: Integer -> TimeStamp
hours :: Integer -> TimeStamp
hours = Integer -> TimeStamp
secondsToDiffTime (Integer -> TimeStamp)
-> (Integer -> Integer) -> Integer -> TimeStamp
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
*3600)
toTime :: TimeStamp -> Rational
toTime :: TimeStamp -> Rational
toTime = TimeStamp -> Rational
forall a. Real a => a -> Rational
toRational
pi :: TimeStamp
pi :: TimeStamp
pi = Double -> TimeStamp
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
forall a. Floating a => a
Prelude.pi
instance Read DiffTime where
readsPrec :: Int -> ReadS TimeStamp
readsPrec p :: Int
p x :: String
x = [ (Double -> TimeStamp
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
tstamp,String
r)
| (tstamp :: Double
tstamp,r :: String
r) <- String -> [(Double, String)]
readNum String
x ]
where readNum ::[Char] -> [(Double, String)]
readNum :: String -> [(Double, String)]
readNum = String -> [(Double, String)]
forall a. Read a => ReadS a
reads (String -> [(Double, String)])
-> (String -> String) -> String -> [(Double, String)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> String -> String
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/='s')