all repos

onasty @ 08f207c458efecb7ecf79920fcecfc818609a8d2

a one-time notes service

onasty/web/src/Time/Format.elm (view raw)

Olexandr Smirnov Olexandr Smirnov
ss2316544@gmail.com
web: pretty time (#157)..., 11 months ago
1
module Time.Format exposing (toString)
2
3
import DateFormat
4
import Time exposing (Posix, Zone)
5
6
7
{-| Formats a given `Posix` time and `Zone` into a human-readable string.
8
9
    toString zone posix
10
        > "July 2nd, 2025 21:05"
11
12
-}
13
toString : Zone -> Posix -> String
14
toString =
15
    DateFormat.format
16
        [ DateFormat.monthNameFull
17
        , DateFormat.text " "
18
        , DateFormat.dayOfMonthSuffix
19
        , DateFormat.text ", "
20
        , DateFormat.yearNumber
21
        , DateFormat.text " "
22
        , DateFormat.hourMilitaryFromOneNumber
23
        , DateFormat.text ":"
24
        , DateFormat.minuteFixed
25
        ]