{-# OPTIONS -fno-warn-missing-methods #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE EmptyDataDecls #-}
module Data.Time
(
getCurrentTime
,fromGregorian
,UTCTime
,Day
,utctDay
,showTime
,showDay)
where
import Data.Data
import Data.Text
import FFI
import Prelude (Show,Eq,Ord,Int)
data UTCTime
deriving (Typeable)
instance Data UTCTime
instance Show UTCTime
instance Eq UTCTime
instance Ord UTCTime
data Day
deriving (Typeable)
instance Data Day
instance Show Day
instance Eq Day
instance Ord Day
getCurrentTime :: Fay UTCTime
getCurrentTime = ffi "(new Date()).getTime()"
fromGregorian :: Int
-> Int
-> Int
-> Day
fromGregorian = ffi "Date.UTC(%1,%2-1,%3)"
utctDay :: UTCTime -> Day
utctDay = ffi "%1"
showTime :: UTCTime -> Text
showTime = ffi "new Date(%1).toString()"
showDay :: Day -> Text
showDay =
ffi "(%1).getUTCFullYear() + ' ' + ((%1).getUTCMonth() + 1) + ' ' + ((%1).getUTCDate() + 1)"