Skip to content
Snippets Groups Projects
Commit 3c403661 authored by Timur Safin's avatar Timur Safin Committed by Kirill Yukhin
Browse files

datetime, lua: date parsing functions

Datetime module provides parse function to create
datetime object given input string.

`datetime.parse` function expect 1 required argument - which is
input string, and set of optional parameters passed as table
in 2nd argument.

Allowed attributes in this optional table are:
* `format` - should be either 'iso8601', 'rfc3339' or `strptime`-like
  format string. [strptime format will be added as part of next
  commit];
* `tzoffset` - to redefine offset of input string value, if there
  is no timezone provided.
* `tz` - human-readable, Olson database, timezone identifier, e.g.
  'Europe/Moscow'. Not yet implemented in this commit.

```
tarantool> T = date.parse('1970-01-01T00:00:00Z')

tarantool> T
- 1970-01-01T00:00:00Z

tarantool> T = date.parse('1970-01-01T00:00:00',
                          {format = 'iso8601', tzoffset = 180})

tarantool> T
- 1970-01-01T00:00:00+0300

tarantool> T = date.parse('2017-12-27T18:45:32.999999-05:00',
                          {format = 'rfc3339'})

tarantool> T
- 2017-12-27T18:45:32.999999-0500
```

Implemented as per RFC https://hackmd.io/@Mons/S1Vfc_axK#%D0%AD%D1%82%D0%B0%D0%BF-3-%D0%9F%D0%B0%D1%80%D1%81%D0%B8%D0%BD%D0%B3-%D0%B4%D0%B0%D1%82-%D0%BF%D0%BE-%D1%84%D0%BE%D1%80%D0%BC%D0%B0%D1%82%D1%83

Part of #6731

NO_DOC=internal
NO_CHANGELOG=internal
parent 1b1ddd22
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment