module Data.Time.Hora.Stamp
(
Now(..),
Timestamp(..),
ts') where
import Data.Time.Clock
import Data.Time.Hora.Format
import Data.Time.Hora.Part
import Data.Time.Hora.Type
import Data.Time.LocalTime as L
class Now a where
now::IO a
instance Integral a => Now (DatePart a) where
now = withUTCTime fromUtc
instance Now UTCTime where
now = getCurrentTime
instance Integral a => Now (Tz (DatePart a)) where
now = withTimeZone fromUtc'
withTimeZone::(TimeZone -> UTCTime -> Tz a) -> IO (Tz a)
withTimeZone fn0 = do
z1 <- getCurrentTimeZone
t1 <- getCurrentTime
pure $ fn0 z1 t1
withUTCTime::(UTCTime -> a) -> IO a
withUTCTime fn0 = do
t1 <- getCurrentTime
pure $ fn0 t1
class Timestamp out where
ts::[Format] -> IO out
instance Timestamp String where
ts lf0 = withUTCTime $ format lf0
instance Timestamp (Tz String) where
ts lf0 = withTimeZone $ format' lf0
ts'::Tz' tz => [Format] -> tz -> IO (Tz String)
ts' lf0 tz0 = withUTCTime $ format' lf0 tz0