Skip to content

Commit ec0ad3d

Browse files
committed
Add async datetime parameter tests and document timezone handling
1 parent 27a696a commit ec0ad3d

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

docs/types.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ Date and time
184184
* - ``PrimitiveType.Interval64``
185185
- extended-range interval
186186

187+
.. note::
188+
189+
When a ``datetime.datetime`` is passed for ``Datetime``, ``Datetime64``,
190+
``Timestamp`` or ``Timestamp64``, a tz-naive value is written as-is (its
191+
wall-clock value), while a tz-aware value is converted to UTC first.
192+
Integer inputs (seconds for ``Datetime``/``Datetime64``, microseconds for
193+
``Timestamp``/``Timestamp64`` since the Unix epoch) are still accepted.
194+
187195
Other
188196
^^^^^
189197

tests/aio/test_types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ async def test_types(driver, database, value, ydb_type):
5959
@pytest.mark.parametrize(
6060
"value,ydb_type,result_value",
6161
[
62-
# FIXME: TypeError: 'datetime.datetime' object cannot be interpreted as an integer
63-
# (test_dt_today, "Datetime", test_dt_today),
6462
(test_today, "Date", test_today),
6563
(365, "Date", date(1971, 1, 1)),
6664
(3600 * 24 * 365, "Datetime", datetime(1971, 1, 1, 0, 0)),
65+
(datetime(1971, 1, 1, 0, 0), "Datetime", datetime(1971, 1, 1, 0, 0)),
66+
(datetime(1970, 1, 1, 4, 0, tzinfo=tz4h), "Datetime", datetime(1970, 1, 1, 0, 0)),
67+
(datetime(1969, 1, 1, 0, 0), "Datetime64", datetime(1969, 1, 1, 0, 0)),
6768
(datetime(1970, 1, 1, 4, 0, tzinfo=tz4h), "Timestamp", datetime(1970, 1, 1, 0, 0)),
6869
(test_td, "Interval", test_td),
6970
(test_now, "Timestamp", test_now),

0 commit comments

Comments
 (0)