From 9f9ee7d8574ea6fbc0893fa36f7f79d4c0dac709 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Wed, 14 Feb 2024 08:27:36 -0500 Subject: [PATCH] Format time (in UTC) --- src/Component/Thread/Intro.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Component/Thread/Intro.hs b/src/Component/Thread/Intro.hs index ece0950..77c19fc 100644 --- a/src/Component/Thread/Intro.hs +++ b/src/Component/Thread/Intro.hs @@ -18,10 +18,16 @@ import Miso import GHCJS.DOM.Types (JSString) import Data.Foldable (toList) import Miso.String (toMisoString) +import Data.Time.Clock (UTCTime) +import Data.Time.Format (formatTime, defaultTimeLocale) import Network.PostType (Post) import qualified Network.PostType as Post +formatUTC :: UTCTime -> JSString +formatUTC time = toMisoString $ + formatTime defaultTimeLocale "%Y-%m-%d (%a) %T" time + intro :: Post -> View a intro post = span_ [ class_ "intro" ] @@ -32,10 +38,10 @@ intro post = span_ -- TODO: Add flags (don't have that data in the db yet) , " " , time_ - [ textProp "datetime" "2024-01-19T11:53:33Z" + [ textProp "datetime" $ toMisoString $ show $ creation_time , textProp "data-local" "true" - , title_ "14 days ago" - ][ "2024-01-19 (Fri) 06:53:33" ] + -- , title_ "14 days ago" + ][ text $ formatUTC creation_time ] , " " , a_ [ class_ "post_no" @@ -50,6 +56,8 @@ intro post = span_ ) where + creation_time = Post.creation_time post + subject :: [ View a ] subject = map (mkSubject . toMisoString) $ toList $ Post.subject post