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 Control.Concurrent.STM.Delay
|
||||||
|
|
||||||
import Language.Haskell.TH (stringE,runIO)
|
|
||||||
|
|
||||||
-- import Data.FileEmbed (embedStringFile)
|
-- import Data.FileEmbed (embedStringFile)
|
||||||
|
|
||||||
getHealthR :: Handler TypedContent
|
getHealthR :: Handler TypedContent
|
||||||
@ -123,15 +121,13 @@ getStatusR = do
|
|||||||
Uptime: #{show $ ddays starttime currtime} days.
|
Uptime: #{show $ ddays starttime currtime} days.
|
||||||
<p>
|
<p>
|
||||||
Compile Time <br>
|
Compile Time <br>
|
||||||
#{comptime} #
|
#{show cTime} #
|
||||||
$maybe ctime <- readMay comptime
|
Build age: #{show $ ddays cTime currtime} days.
|
||||||
Build age: #{show $ ddays ctime currtime} days.
|
|
||||||
|]
|
|]
|
||||||
where
|
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 :: UTCTime -> UTCTime -> Double
|
||||||
ddays tstart tstop = (/100) $ fromIntegral $ round $ diffUTCTime tstop tstart / (36 * 24)
|
ddays tstart tstop = (/100) $ fromIntegral $ round $ diffUTCTime tstop tstart / (36 * 24)
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
module Utils.DateTime
|
module Utils.DateTime
|
||||||
( timeLocaleMap
|
( timeLocaleMap
|
||||||
, TimeLocale(..)
|
, TimeLocale(..)
|
||||||
|
, compileTime
|
||||||
, currentYear
|
, currentYear
|
||||||
, HasLocalTime(..)
|
, HasLocalTime(..)
|
||||||
, DateTimeFormat(..)
|
, DateTimeFormat(..)
|
||||||
@ -79,6 +80,11 @@ timeLocaleMap extra@((_, defLocale):_) = do
|
|||||||
|
|
||||||
letE [localeMap'] (varE localeMap)
|
letE [localeMap'] (varE localeMap)
|
||||||
|
|
||||||
|
compileTime :: ExpQ -- Type UTCTime
|
||||||
|
compileTime = do
|
||||||
|
now <- runIO getCurrentTime
|
||||||
|
[e|now|]
|
||||||
|
|
||||||
currentYear :: ExpQ
|
currentYear :: ExpQ
|
||||||
currentYear = do
|
currentYear = do
|
||||||
now <- runIO getCurrentTime
|
now <- runIO getCurrentTime
|
||||||
|
|||||||
Reference in New Issue
Block a user