Tarantool supports datetime interval type since version 2.10.0 [1]. This patch introduced the support of Tarantool interval type in msgpack decoders and encoders.
Tarantool datetime interval objects are decoded to tarantool.Interval type. tarantool.Interval may be encoded to Tarantool interval objects.
You can create tarantool.Interval objects either from msgpack data or by using the same API as in Tarantool:
di = tarantool.Interval(year=-1, month=2, day=3,
hour=4, minute=-5, sec=6,
nsec=308543321,
adjust=tarantool.IntervalAdjust.NONE)
Its attributes (same as in init API) are exposed, so you can use them if needed.
datetime, numpy and pandas tools doesn't seem to be sufficient to cover all adjust cases supported by Tarantool.
This patch does not yet introduce the support of datetime interval arithmetic.
tarantool.IntervalAdjust.EXCESS -- overflow mode, without any snap or truncation to the end of month, straight addition of days in month, stopping over month boundaries if there is less number of days.
Tarantool does not yet correctly support subtraction of datetime objects with different timezones [2] and addition of intervals to datetimes with non-fixed offset timezones [3]. tarantool-python implementation support them, but it could be reworked later if core team choose another solution.
msgpack: support datetime interval extended type
Tarantool supports datetime interval type since version 2.10.0 [1]. This patch introduced the support of Tarantool interval type in msgpack decoders and encoders.
Tarantool datetime interval objects are decoded to
tarantool.Interval
type.tarantool.Interval
may be encoded to Tarantool interval objects.You can create
tarantool.Interval
objects either from msgpack data or by using the same API as in Tarantool:Its attributes (same as in init API) are exposed, so you can use them if needed.
datetime, numpy and pandas tools doesn't seem to be sufficient to cover all adjust cases supported by Tarantool.
This patch does not yet introduce the support of datetime interval arithmetic.
Part of #229
msgpack: support datetime interval arithmetic
Support datetime and interval arithmetic with the same rules as in Tarantool [1].
Valid operations:
tarantool.Datetime
+tarantool.Interval
=tarantool.Datetime
tarantool.Datetime
-tarantool.Interval
=tarantool.Datetime
tarantool.Datetime
-tarantool.Datetime
=tarantool.Interval
tarantool.Interval
+tarantool.Interval
=tarantool.Interval
tarantool.Interval
-tarantool.Interval
=tarantool.Interval
Since
tarantool.Interval
could containmonth
andyear
fields and such operations could be ambiguous, you can useadjust
field to tune the logic.tarantool.IntervalAdjust.NONE
-- only truncation toward the end of month performed (default mode).tarantool.IntervalAdjust.EXCESS
-- overflow mode, without any snap or truncation to the end of month, straight addition of days in month, stopping over month boundaries if there is less number of days.tarantool.IntervalAdjust.LAST
-- mode when day snaps to the end of month, if happens.Tarantool does not yet correctly support subtraction of datetime objects with different timezones [2] and addition of intervals to datetimes with non-fixed offset timezones [3]. tarantool-python implementation support them, but it could be reworked later if core team choose another solution.
Closes #229