refactor: add compileTime via template Haskell to Utils.DateTime
This commit is contained in:
parent
439520794d
commit
bb7ddcdd20
@ -13,8 +13,6 @@ import qualified Data.Set as Set
|
||||
|
||||
import Control.Concurrent.STM.Delay
|
||||
|
||||
import Language.Haskell.TH (stringE,runIO)
|
||||
|
||||
-- import Data.FileEmbed (embedStringFile)
|
||||
|
||||
getHealthR :: Handler TypedContent
|
||||
@ -123,15 +121,13 @@ getStatusR = do
|
||||
Uptime: #{show $ ddays starttime currtime} days.
|
||||
<p>
|
||||
Compile Time <br>
|
||||
#{comptime} #
|
||||
$maybe ctime <- readMay comptime
|
||||
Build age: #{show $ ddays ctime currtime} days.
|
||||
#{show cTime} #
|
||||
Build age: #{show $ ddays cTime currtime} days.
|
||||
|]
|
||||
where
|
||||
-- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible during container construction
|
||||
-- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible during container construction
|
||||
cTime :: UTCTime
|
||||
cTime = $compileTime
|
||||
|
||||
comptime :: Text
|
||||
comptime = $(stringE =<< runIO (show <$> getCurrentTime))
|
||||
|
||||
ddays :: UTCTime -> UTCTime -> Double
|
||||
ddays tstart tstop = (/100) $ fromIntegral $ round $ diffUTCTime tstop tstart / (36 * 24)
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
module Utils.DateTime
|
||||
( timeLocaleMap
|
||||
, TimeLocale(..)
|
||||
, compileTime
|
||||
, currentYear
|
||||
, HasLocalTime(..)
|
||||
, DateTimeFormat(..)
|
||||
@ -79,6 +80,11 @@ timeLocaleMap extra@((_, defLocale):_) = do
|
||||
|
||||
letE [localeMap'] (varE localeMap)
|
||||
|
||||
compileTime :: ExpQ -- Type UTCTime
|
||||
compileTime = do
|
||||
now <- runIO getCurrentTime
|
||||
[e|now|]
|
||||
|
||||
currentYear :: ExpQ
|
||||
currentYear = do
|
||||
now <- runIO getCurrentTime
|
||||
|
||||
Loading…
Reference in New Issue
Block a user