foliage/app/Foliage/Time.hs
Andrea Bedini 080197e9e2
Big rewrite
1. Foliage takes as input a complete description of the index, where
   source distributions and revisions come with a timestamp. This allows
   us to recreate the entire index in a reproducible way.

2. Added a experimental command to import an index from a Hackage (as
   downloaded with Cabal). This was originally a testing/development
   need but there might be different use cases.
2022-03-28 17:18:27 +08:00

28 lines
609 B
Haskell

{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Foliage.Time
( iso8601ParseM,
iso8601Show,
getCurrentTime,
UTCTime (..),
utcTimeToPOSIXSeconds,
addUTCTime,
nominalDay,
truncateSeconds,
)
where
import Data.Time
import Data.Time.Clock.POSIX
import Data.Time.Compat ()
import Data.Time.Format.ISO8601
import Development.Shake.Classes
instance Binary UTCTime where
get = iso8601ParseM =<< get
put = put . iso8601Show
truncateSeconds :: UTCTime -> UTCTime
truncateSeconds = posixSecondsToUTCTime . fromIntegral @Int . floor . utcTimeToPOSIXSeconds