hledger/hledger-web/Handler/Utils.hs
2018-06-24 14:13:03 +02:00

17 lines
471 B
Haskell

{-# LANGUAGE CPP #-}
-- | Web handler utilities. More of these are in Foundation.hs, where
-- they can be used in the default template.
module Handler.Utils where
import Data.Time.Calendar
import Data.Time.Clock
import Data.Time.Format
numbered :: [a] -> [(Int,a)]
numbered = zip [1..]
dayToJsTimestamp :: Day -> Integer
dayToJsTimestamp d = read (formatTime defaultTimeLocale "%s" t) * 1000 -- XXX read
where t = UTCTime d (secondsToDiffTime 0)