Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/f0i/iso8601
Elm package to format elm/time posix time as an ISO8601 strings for humans
https://github.com/f0i/iso8601
elm iso8601
Last synced: about 1 month ago
JSON representation
Elm package to format elm/time posix time as an ISO8601 strings for humans
- Host: GitHub
- URL: https://github.com/f0i/iso8601
- Owner: f0i
- License: bsd-3-clause
- Created: 2020-03-22T13:08:50.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-05T13:06:41.000Z (over 3 years ago)
- Last Synced: 2023-08-08T20:39:19.058Z (over 1 year ago)
- Topics: elm, iso8601
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/f0i/iso8601/latest/
- Size: 9.77 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Iso8601
Format a [posix time](https://package.elm-lang.org/packages/elm/time/latest/) to a ISO8601 String.
This package is intended to format time stamps for user interfaces with custom precision.
## Install
```
elm install f0i/iso8601
```## Examples
See [guide.elm-lang.org/…/time.html](https://guide.elm-lang.org/effects/time.html) for how to get the current time.
```elm
import Iso8601
import Time exposing (Posix)...
-- get a Posix time from elm/time
time =
Time.millisToPosix 1584875883199-- this will format the time as "2020-03-22T11:18:03.199"
milli =
Iso8601.toUtcMilliString time-- this will format the time as "2020-03-22T11:18"
minute =
Iso8601.toUtcString Iso8601.Minute time-- this will format the time as "11:18:03"
hourToSecond =
Iso8601.toUtcString Iso8601.HourSecond time-- or get each part of the String as Tuple to create a custom format
custom =
let
( ( year, month, day ), ( hour, minute, second ), ms ) =
Iso8601.toTuple time
in
year ++ "/" ++ month ++ "/" ++ day ++ " " ++ hour ++ "_" ++ minute ++ "!"
```A complete list of the helper functions can be found in the
[Iso8601 module docs](Iso8601).