datetime: Olson timezones changelog and doc request
Use Olson/IANA tzdata for timezone handling in datetime string. Closes of #6751 NO_TEST=doc @TarantoolBot document Title: Document timezone support Timezones support ----------------- Tarantool uses IANA tzdata aka Olson DB facilities for timezone resolution at the moment of parsing of datetime literals or while parsing `tz` attribute in constructor, or `:set{}` method call. In addition to the `tzoffset` we provided before, we now define `tzindex`, the unique index assigned by Tarantool to each known IANA timezone. ```lua date = require 'datetime' tarantool> T = date.parse '2022-01-01T00:00 Europe/Moscow' tarantool> T.tzindex --- - 947 ... tarantool> T.tzoffset --- - 180 ... tarantool> T.tz --- - Europe/Moscow ... ``` Now `date.isdst` field (alone and as part of `:totable()` table) is correctly calculated using `tzindex` and attributes of the selected timezone in the Olson DB timezone. ``` tarantool> date.parse('2004-06-01T00:00 Europe/Moscow').isdst --- - true ... tarantool> date.parse('2004-12-01T00:00 Europe/Moscow'):totable() --- - sec: 0 min: 0 yday: 336 day: 1 nsec: 0 isdst: false wday: 4 tzoffset: 180 month: 12 year: 2004 hour: 0 ... ``` All timezone names and abbreviations, known to the current Tarantool version are available via `datetime.TZ` bidirectional array. ```lua print(date.TZ['Europe/Moscow']) -- 947 print(date.TZ[947]) -- Europe/Moscow ``` Limitations ----------- There were moments in past history, when local mean time in some partcular zone used timezone offset not representable in whole minutes, but rather in seconds, i.e. in Moscow before 1918 there used to be offset +2 hours 31 minutes and 19 seconds. Please see Olson dump for this period ``` $ ./src/lib/tzcode/install/usr/bin/zdump -c1880,1918 -i Europe/Moscow TZ="Europe/Moscow" - - +023017 MMT 1916-07-03 00:01:02 +023119 MMT 1917-07-02 00 +033119 MST 1 1917-12-27 23 +023119 MMT ``` Modern tzdata rules do not use such tiny fraction, and all timezones differ to UTC in units measured in minutes, not seconds. Tarantool datetime uses minutes internally as units for `tzoffset` so there is some loss of precision if you try to operate with such ancient timestamps. (cherry picked from commit 979a8fbd)
Loading
Please register or sign in to comment