onasty/web/src/Time/Format.elm (view raw)
| 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 | ] |