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

datetime, lua: strptime-like parse format

To parse date/time strings using format string we use
`strptime()` implementation from FreeBSD, which is
modified to use our `struct datetime` data structure.

List of supported format has been extended to include
`%f` which is flag used whenever you need to process
nanoseconds part of datetime value.

```
tarantool> T = date.parse('Thu Jan  1 03:00:00 1970', {format = '%c'})

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

tarantool> T = date.parse('12/31/2020', {format = '%m/%d/%y'})

tarantool> T
- 2020-12-31T00:00:00Z

tarantool> T = date.parse('1970-01-01T03:00:00.125000000+0300',
                          {format = '%FT%T.%f%z'})

tarantool> T
- 1970-01-01T03:00:00.125+0300
```

Part of #6731

NO_DOC=internal
NO_CHANGELOG=internal
parent 3c403661
No related branches found
No related tags found
No related merge requests found
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