1
0
mirror of https://github.com/avinal/avinal.github.io.git synced 2026-07-03 23:30:09 +05:30

change time formatting

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
2023-04-14 19:26:05 +05:30
parent 35dc64bbbf
commit b20d3de614
4 changed files with 32 additions and 23 deletions
+2 -2
View File
@@ -109,7 +109,7 @@ view model =
[ Html.a [ href <| "/posts/" ++ first.category ++ "/" ++ first.slug ]
[ Html.h3 [ class "text-2xl font-semibold sm:text-4xl group-hover:underline group-focus:underline" ]
[ Html.text first.title ]
, Html.time [ class "text-gray-400", datetime first.date ] [ Html.text <| UU.getFormattedDate first.date ]
, Html.time [ class "text-gray-400", datetime first.date ] [ Html.text <| UU.getFormattedDate first.date True ]
, Html.p [] [ Html.text <| String.left 200 first.description ]
]
, Html.a [ href <| "/posts/" ++ first.category, target "_blank" ] [ UU.categoryNtags first.category [] ]
@@ -128,7 +128,7 @@ view model =
, Html.div [ class "p-6 space-y-2" ]
[ Html.a [ href <| "/posts/" ++ blog.category ++ "/" ++ blog.slug ]
[ Html.h3 [ class "text-2xl font-semibold group-hover:underline group-focus:underline" ] [ Html.text blog.title ]
, Html.time [ class " text-gray-400", datetime blog.date ] [ Html.text <| UU.getFormattedDate blog.date ]
, Html.time [ class " text-gray-400", datetime blog.date ] [ Html.text <| UU.getFormattedDate blog.date True ]
, Html.p [] [ Html.text <| String.left 200 blog.description ]
]
, Html.a [ href <| "/posts/" ++ blog.category, target "_blank" ] [ UU.categoryNtags blog.category [] ]
+1 -1
View File
@@ -109,7 +109,7 @@ view model =
]
, Html.div [ class "grow-0 shrink-0 basis-auto w-full md:w-9/12 xl:w-7/12 p-3 md:mb-0 mr-auto bg-neutral-900" ]
[ Html.h5 [ class "text-2xl font-bold mb-2" ] [ Html.text blog.title ]
, Html.time [ class "text-gray-400 text-sm", datetime blog.date ] [ Html.text <| UU.getFormattedDate blog.date ]
, Html.time [ class "text-gray-400 text-sm", datetime blog.date ] [ Html.text <| UU.getFormattedDate blog.date True ]
, Html.p [ class "text-gray-500 mt-4 text-md" ] [ Html.text <| String.left 200 blog.description ]
]
]
+2 -12
View File
@@ -139,7 +139,7 @@ view model =
[ Html.text "By "
, Html.a [ href "https://avinal.space/pages/about-me", class "font-bold no-underline hover:text-pink-500" ] [ Html.text "Avinal Kumar" ]
, Html.text " on "
, Html.time [ datetime blog.meta.date ] [ Html.text <| UU.getFormattedDate blog.meta.date ]
, Html.time [ datetime blog.meta.date ] [ Html.text <| UU.getFormattedDate blog.meta.date True ]
]
, Html.span [ class "text-base font-light float-right" ] [ Html.a [ href "", class "hover:text-pink-500" ] [ Html.abbr [ class "fa-solid fa-link no-underline", title "Share this article" ] [] ] ]
, articleNode blog.content model.fragment blog.meta.title blog.meta.description
@@ -160,7 +160,7 @@ view model =
, body =
[ case model.error of
Just err ->
errorView err
UU.errorView err
Nothing ->
Html.div [ class "flex items-center justify-center flex-col object-cover object-center " ]
@@ -169,16 +169,6 @@ view model =
}
errorView : String -> Html msg
errorView error =
Html.div
[ class "border border-red-400 text-red-700 px-4 py-3 rounded relative" ]
[ Html.strong [ class "text-red-400" ] [ Html.text "Something bad has happened!" ]
, Html.br [] []
, Html.text ("Error: " ++ error)
]
articleNode : String -> String -> String -> String -> Html Msg
articleNode data fragment title description =
Html.node "rendered-md"
+27 -8
View File
@@ -17,8 +17,8 @@ type alias DateTime =
}
getFormattedDate : String -> String
getFormattedDate dateString =
getFormattedDate : String -> Bool -> String
getFormattedDate dateString time =
case Parser.run dateParser dateString of
Ok date ->
(Maybe.withDefault "Month" <| Array.get (date.month - 1) months)
@@ -26,14 +26,23 @@ getFormattedDate dateString =
++ String.fromInt date.day
++ ", "
++ String.fromInt date.year
++ ", "
++ String.fromInt date.hour
++ ":"
++ String.fromInt date.minute
++ " IST"
++ (if time then
", "
++ String.fromInt date.hour
++ ":"
++ String.fromInt date.minute
++ " IST"
else
""
)
Err _ ->
"Invalid date!!"
if time then
"Invalid date!!"
else
"Present"
dateParser : Parser DateTime
@@ -99,3 +108,13 @@ errorToString error =
BadBody errorMessage ->
errorMessage
errorView : String -> Html msg
errorView error =
Html.div
[ class "border border-red-400 text-red-700 px-4 py-3 rounded relative" ]
[ Html.strong [ class "text-red-400" ] [ Html.text "Something bad has happened!" ]
, Html.br [] []
, Html.text ("Error: " ++ error)
]