You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support non-zero tzindex in datetime extended type. If both tzoffset and
tzindex are specified, tzindex is prior (same as in Tarantool [1]).
Tarantool index to Olson name map and inverted one are built with
gen_timezones.sh script based on tarantool/go-tarantool script [2].
Both Tarantool and pytz [3] are based on Olson tz database, yet there
are some differences in their list of supported timezones.
If you are using `pytz.FixedOffset` or non-abbreviated timezone
(like 'Europe/Moscow'), everything is alright.
If you are using abbreviated timezone, this is where everithing
may become tricky. pytz do not support most Tarantool
abbreviated timezones (except for CET, EET, EST, GMT, HST, MST, UTC,
WET). If Tarantool abbreviated timezone is not supported by pytz,
we create a timestamp with corresponding `pytz.FixedOffset` instead.
`tarantool.Datetime` stores `tzindex` info, so nothing will be lost on
encoding/decoding. If you want to create a datetime with non-pytz
abbreviated timezone in python, you may use
`tarantool.Datetime(tarantool_tzindex=tzindex)` argument. If you convert
`tarantool.Datetime` with non-pytz abbreviated timezone to
`pandas.Timestamp`, `tzindex` data will be lost on conversion. You may
call `tzindex()` getter of `tarantool.Datetime` to extract tzindex data
to use it later.
There are some pytz timezones not supported by Tarantool: CST6CDT,
EST5EDT, MET, MST7MDT, PST8PDT, Europe/Kyiv and all Etc/GMT* timezones
(except for Etc/GMT, Etc/GMT+0, Etc/GMT-0). They are treated as
`pytz.FixedOffset` on encoding. The warning is is raised in this case.
pytz does not natively support work with abbreviated timezones due to
its possibly ambiguous nature [4-6]. Tarantool itself do not support
work with ambiguous abbreviated timezones:
```
Tarantool 2.10.1-0-g482d91c66
tarantool> datetime.new({tz = 'BST'})
---
- error: 'builtin/datetime.lua:477: could not parse ''BST'' - ambiguous timezone'
...
```
If ambiguous timezone is specified, the exception is raised.
Tarantool header timezones.h [7] provides a map for all abbreviated
timezones with category info (all ambiguous timezones are marked with
TZ_AMBIGUOUS flag) and offset info. We parse this info to build
pytz.fixedOffset() timezone for each Tarantool abbreviated timezone not
supported natively by pytz.
1. https://www.tarantool.io/en/doc/latest/reference/reference_lua/datetime/new/
2. https://github.com/tarantool/go-tarantool/blob/5801dc6f5ce69db7c8bc0c0d0fe4fb6042d5ecbc/datetime/gen-timezones.sh
3. https://pypi.org/project/pytz/
4. https://stackoverflow.com/questions/37109945/how-to-use-abbreviated-timezone-namepst-ist-in-pytz
5. https://stackoverflow.com/questions/27531718/datetime-timezone-conversion-using-pytz
6. https://stackoverflow.com/questions/30315485/pytz-return-olson-timezone-name-from-only-a-gmt-offset
7. https://github.com/tarantool/tarantool/9ee45289e01232b8df1413efea11db170ae3b3b4/src/lib/tzcode/timezones.h
0 commit comments