Skip to content

Document timezone support #2886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TarantoolBot opened this issue May 20, 2022 · 0 comments · Fixed by #4429
Closed

Document timezone support #2886

TarantoolBot opened this issue May 20, 2022 · 0 comments · Fixed by #4429
Assignees
Labels
datetime feature A new functionality reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality

Comments

@TarantoolBot
Copy link
Collaborator

TarantoolBot commented May 20, 2022

Product: Tarantool
Since:
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/
SME: @ ligurio

Related to #2574

Details

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.

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.

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.
Requested by @ tsafin in tarantool/tarantool@979a8fb.

@xuniq xuniq added feature A new functionality reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality 3sp labels May 23, 2022
@veod32 veod32 added datetime and removed 3sp labels Mar 1, 2023
@andreyaksenov andreyaksenov self-assigned this Aug 5, 2024
@andreyaksenov andreyaksenov linked a pull request Aug 5, 2024 that will close this issue
@andreyaksenov andreyaksenov removed their assignment Aug 5, 2024
@andreyaksenov andreyaksenov removed a link to a pull request Aug 5, 2024
ligurio added a commit that referenced this issue Aug 12, 2024
@ligurio ligurio self-assigned this Aug 12, 2024
ligurio added a commit that referenced this issue Aug 12, 2024
ligurio added a commit that referenced this issue Aug 12, 2024
ligurio added a commit that referenced this issue Aug 13, 2024
Closes #2886

Co-authored-by: Andrey Aksenov <[email protected]>
ligurio added a commit that referenced this issue Aug 13, 2024
Closes #2886

Co-authored-by: Andrey Aksenov <[email protected]>
ligurio added a commit that referenced this issue Aug 13, 2024
Closes #2886

Co-authored-by: Andrey Aksenov <[email protected]>
ligurio added a commit that referenced this issue Aug 13, 2024
Closes #2886

Co-authored-by: Andrey Aksenov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datetime feature A new functionality reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants