Skip to content

datetime: timezone support #4429

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

Merged
merged 1 commit into from
Aug 13, 2024
Merged

Conversation

ligurio
Copy link
Member

@ligurio ligurio commented Aug 12, 2024

@ligurio ligurio force-pushed the ligurio/gh-2886-timezone-support branch from 148f07a to 3f2e6fe Compare August 12, 2024 15:56
@ligurio ligurio requested a review from andreyaksenov August 12, 2024 15:58
@ligurio ligurio force-pushed the ligurio/gh-2886-timezone-support branch from 3f2e6fe to 30329cf Compare August 12, 2024 18:11
Copy link
Contributor

@andreyaksenov andreyaksenov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments below:

@ligurio ligurio force-pushed the ligurio/gh-2886-timezone-support branch from 7306639 to ddc03d3 Compare August 13, 2024 08:03
@ligurio
Copy link
Member Author

ligurio commented Aug 13, 2024

Added:

diff --git a/doc/reference/reference_lua/datetime.rst b/doc/reference/reference_lua/datetime.rst
index 32401669..292a0aef 100644
--- a/doc/reference/reference_lua/datetime.rst
+++ b/doc/reference/reference_lua/datetime.rst
@@ -541,7 +541,8 @@ datetime_object
 
         Modify an existing datetime object by adding values of the input argument.
         See also: :ref:`interval_arithm`. The addition is performed taking ``tzdata``
-        into account ``tzoffset`` or ``tz`` fields are set.
+        into account, when ``tzoffset`` or ``tz`` fields are set, see the :ref:`timezone`
+        and the :ref:`interval_arithm` sections.
 
         :param table input: an :ref:`interval object <interval_obj>` or an equivalent table (see **Example #1**)
         :param string adjust: defines how to round days in a month after an arithmetic operation.
@@ -723,7 +724,8 @@ datetime_object
 
         Modify an existing datetime object by subtracting values of the input argument.
         See also: :ref:`interval_arithm`. The subtraction is performed taking ``tzdata``
-        into account ``tzoffset`` or ``tz`` fields are set.
+        into account, when ``tzoffset`` or ``tz`` fields are set, see the :ref:`timezone`
+        and the :ref:`interval_arithm` sections.
 
         :param table input: an :ref:`interval object <interval_obj>` or an equivalent table (see **Example**)
         :param string adjust: defines how to round days in a month after an arithmetic operation.
@@ -1021,6 +1023,16 @@ The matrix of the ``subtraction`` operands eligibility and their result types:
             -   interval
             -   interval
 
+The subtraction and addition of datetime objects are performed taking ``tzdata``
+into account ``tzoffset`` or ``tz`` fields are set:
+
+..  code-block:: tarantoolsession
+
+    tarantool> datetime.new({tz='MSK'}) - datetime.new({tz='UTC'})
+    ---
+    - -180 minutes
+    ...
+
 .. _interval_comp:
 
 Datetime and interval comparison

@ligurio ligurio force-pushed the ligurio/gh-2886-timezone-support branch from ddc03d3 to 458ab62 Compare August 13, 2024 08:39
@ligurio
Copy link
Member Author

ligurio commented Aug 13, 2024

Updated:

diff --git a/doc/reference/reference_lua/datetime.rst b/doc/reference/reference_lua/datetime.rst
index 292a0aef..d785fe83 100644
--- a/doc/reference/reference_lua/datetime.rst
+++ b/doc/reference/reference_lua/datetime.rst
@@ -541,8 +541,7 @@ datetime_object
 
         Modify an existing datetime object by adding values of the input argument.
         See also: :ref:`interval_arithm`. The addition is performed taking ``tzdata``
-        into account, when ``tzoffset`` or ``tz`` fields are set, see the :ref:`timezone`
-        and the :ref:`interval_arithm` sections.
+        into account, when ``tzoffset`` or ``tz`` fields are set, see the :ref:`timezone`.
 
         :param table input: an :ref:`interval object <interval_obj>` or an equivalent table (see **Example #1**)
         :param string adjust: defines how to round days in a month after an arithmetic operation.
@@ -724,8 +723,7 @@ datetime_object
 
         Modify an existing datetime object by subtracting values of the input argument.
         See also: :ref:`interval_arithm`. The subtraction is performed taking ``tzdata``
-        into account, when ``tzoffset`` or ``tz`` fields are set, see the :ref:`timezone`
-        and the :ref:`interval_arithm` sections.
+        into account, when ``tzoffset`` or ``tz`` fields are set, see the :ref:`timezone`.
 
         :param table input: an :ref:`interval object <interval_obj>` or an equivalent table (see **Example**)
         :param string adjust: defines how to round days in a month after an arithmetic operation.
@@ -1157,6 +1155,8 @@ Every datetime object has three fields that represent timezone support:
 
 The fields ``tz``, ``tzoffset`` can be set in :ref:`datetime.new() <datetime-new>`,
 :ref:`datetime.parse() <datetime-parse>` and :ref:`datetime_object:set() <datetime-set>`.
+The arithmetic on datetime objects are performed taking ``tzdata`` into account, when
+``tzoffset`` or ``tz`` fields are set, see the :ref:`interval_arithm` section.
 
 Limitations
 -----------

Copy link
Contributor

@andreyaksenov andreyaksenov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A couple of minor things

@ligurio ligurio force-pushed the ligurio/gh-2886-timezone-support branch from 458ab62 to f69c9b5 Compare August 13, 2024 08:52
Closes #2886

Co-authored-by: Andrey Aksenov <[email protected]>
@ligurio ligurio force-pushed the ligurio/gh-2886-timezone-support branch from fe9e6fc to 457abd2 Compare August 13, 2024 08:54
Copy link
Contributor

@andreyaksenov andreyaksenov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Merging

@andreyaksenov andreyaksenov merged commit f61f57f into latest Aug 13, 2024
1 check passed
@andreyaksenov andreyaksenov deleted the ligurio/gh-2886-timezone-support branch August 13, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document timezone support
2 participants