Skip to content

Commit 3ebf25d

Browse files
amotlmfussenegger
andcommitted
Update documentation about obtaining timezone-aware timestamps
Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
1 parent f88d10c commit 3ebf25d

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Unreleased
1111
- SQLAlchemy DDL: Allow setting ``server_default`` on columns to enable
1212
server-generated defaults.
1313

14-
- Allow handling "aware" datetime values with time zone info when inserting or updating.
14+
- Allow handling datetime values tagged with time zone info when inserting or updating.
1515

1616

1717
2023/04/18 0.31.1

docs/by-example/client.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ Refresh locations:
142142
Updating Data
143143
=============
144144

145-
Both when inserting or updating data, values for ``TIMESTAMP`` columns can be obtained
146-
in different formats. Both literal strings and datetime objects are supported.
145+
Values for ``TIMESTAMP`` columns can be obtained as a string literal, ``date``,
146+
or ``datetime`` object. If the datetime object contains timezone information,
147+
it is converted to UTC, and the timezone information is discarded.
147148

148149
>>> import datetime as dt
149150
>>> timestamp_full = "2023-06-26T09:24:00.123+02:00"

docs/data-types.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ __ https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#c
9999

100100
.. NOTE::
101101

102-
Values of ``TIMESTAMP`` columns will always be stored using a ``LONG`` type,
103-
representing the `Unix time`_ (epoch) timestamp, i.e. number of seconds which
104-
have passed since 00:00:00 UTC on Thursday, 1 January 1970.
102+
When using ``date`` or ``datetime`` objects with ``timezone`` information,
103+
the value is implicitly converted to a `Unix time`_ (epoch) timestamp, i.e.
104+
the number of seconds which have passed since 00:00:00 UTC on
105+
Thursday, 1 January 1970.
105106

106107
This means, when inserting or updating records using timezone-aware Python
107108
``datetime`` objects, timezone information will not be preserved. If you

0 commit comments

Comments
 (0)