Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inaka/erlang_iso8601
Erlang ISO 8601 date formatter/parser
https://github.com/inaka/erlang_iso8601
date-formatting erlang erlang-iso8601 iso8601
Last synced: about 2 months ago
JSON representation
Erlang ISO 8601 date formatter/parser
- Host: GitHub
- URL: https://github.com/inaka/erlang_iso8601
- Owner: inaka
- License: mit
- Archived: true
- Fork: true (zerotao/erlang_iso8601)
- Created: 2016-08-18T17:18:07.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-12-08T16:43:18.000Z (almost 4 years ago)
- Last Synced: 2024-09-25T21:51:19.930Z (about 2 months ago)
- Topics: date-formatting, erlang, erlang-iso8601, iso8601
- Language: Erlang
- Homepage:
- Size: 43 KB
- Stars: 4
- Watchers: 19
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# erlang_iso8601 #
Formats and parses ISO 8601 dates. This fork incorporates various improvements
such as [sl45sms](https://www.github.com/sl45sms) parse durations patch aswell
as [tsloughter](https://www.github.com/tsloughter) decimal seconds patch## Usage ##
Add it to your `rebar.config` deps:
```erlang
{'iso8601', ".*", {git, "[email protected]:kivra/erlang_iso8601.git", {tag, "1.2.0"}}}
```Format a timestamp or calendar datetime tuple:
```erlang
> iso8601:now().
<<"2012-02-16T01:06:19Z">>
> iso8601:format(calendar:universal_time()).
<<"2012-02-16T01:06:48Z">>
```Parse a date string or binary:
```erlang
> iso8601:parse(<<"2012-02-16T01:06:48Z">>).
{{2012,2,16},{1,6,48}}
> iso8601:parse("2012-02-16T01:06:48Z").
{{2012,2,16},{1,6,48}}
```Add 1 hour, 2 minutes and 3 seconds to a datetime tuple:
```erlang
> Datetime = iso8601:parse(<<"2012-02-16T01:06:48Z">>).
{{2012,2,16},{1,6,48}}
> iso8601:add_time(Datetime, 1, 2, 3).
{{2012,2,16},{2,8,51}}
```Get interval datetimes list examples:
```erlang
> Intervals = iso8601:parse_interval("R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M").
[{{2009,5,11},{15,30,0}},
{{2010,7,21},{18,0,0}},
{{2011,10,1},{20,30,0}},
{{2013,12,11},{23,0,0}},
{{2015,2,22},{1,30,0}}]
> Intervals = iso8601:parse_interval("2008-03-01T13:00:00Z/P1Y2M10DT2H30M").
> Intervals = iso8601:parse_interval("R5/P1Y2M10DT2H30M").
> Intervals = iso8601:parse_interval("R5/P1Y/2008-03-01T13:00:00Z").
```## Known deficiencies ##
* Does not support expanded year representation.
* Does not support fractional times.
* Does not support ordinal dates.See the [open issues](https://github.com/seansawyer/erlang_iso8601/issues)
for more info.