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
Showing
- extra/exports 3 additions, 0 deletionsextra/exports
- src/lib/core/datetime.c 53 additions, 1 deletionsrc/lib/core/datetime.c
- src/lib/core/datetime.h 18 additions, 0 deletionssrc/lib/core/datetime.h
- src/lua/datetime.lua 89 additions, 0 deletionssrc/lua/datetime.lua
- src/lua/tnt_datetime.c 7 additions, 0 deletionssrc/lua/tnt_datetime.c
- test/app-tap/datetime.test.lua 256 additions, 9 deletionstest/app-tap/datetime.test.lua
- test/unit/datetime.c 105 additions, 69 deletionstest/unit/datetime.c
- third_party/c-dt 1 addition, 1 deletionthird_party/c-dt
Loading
Please register or sign in to comment