Format time (in UTC)

This commit is contained in:
towards-a-new-leftypol 2024-02-14 08:27:36 -05:00
parent 1b819fea2c
commit 9f9ee7d857
1 changed files with 11 additions and 3 deletions

View File

@ -18,10 +18,16 @@ import Miso
import GHCJS.DOM.Types (JSString) import GHCJS.DOM.Types (JSString)
import Data.Foldable (toList) import Data.Foldable (toList)
import Miso.String (toMisoString) import Miso.String (toMisoString)
import Data.Time.Clock (UTCTime)
import Data.Time.Format (formatTime, defaultTimeLocale)
import Network.PostType (Post) import Network.PostType (Post)
import qualified Network.PostType as 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 -> View a
intro post = span_ intro post = span_
[ class_ "intro" ] [ class_ "intro" ]
@ -32,10 +38,10 @@ intro post = span_
-- TODO: Add flags (don't have that data in the db yet) -- TODO: Add flags (don't have that data in the db yet)
, " " , " "
, time_ , time_
[ textProp "datetime" "2024-01-19T11:53:33Z" [ textProp "datetime" $ toMisoString $ show $ creation_time
, textProp "data-local" "true" , textProp "data-local" "true"
, title_ "14 days ago" -- , title_ "14 days ago"
][ "2024-01-19 (Fri) 06:53:33" ] ][ text $ formatUTC creation_time ]
, " " , " "
, a_ , a_
[ class_ "post_no" [ class_ "post_no"
@ -50,6 +56,8 @@ intro post = span_
) )
where where
creation_time = Post.creation_time post
subject :: [ View a ] subject :: [ View a ]
subject = map (mkSubject . toMisoString) $ toList $ Post.subject post subject = map (mkSubject . toMisoString) $ toList $ Post.subject post