diff options
| author | Andrew Rabert <ar@nullsum.net> | 2019-03-24 18:19:32 -0400 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2019-03-24 23:09:36 +0000 |
| commit | 3eecf34beaa0fa2deea9f22baf3b657db412a404 (patch) | |
| tree | bf8d4d3f3564cc4bc999989757874bea755c33ad /doc/src | |
| parent | 953bc66ca66fd8bbc18086bba9218072a9dfb8e7 (diff) | |
| download | psycopg2-3eecf34beaa0fa2deea9f22baf3b657db412a404.tar.gz | |
Add time type conversion info to docs
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/usage.rst | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/src/usage.rst b/doc/src/usage.rst index 08c6dce..07e7d0c 100644 --- a/doc/src/usage.rst +++ b/doc/src/usage.rst @@ -634,6 +634,29 @@ Of course it will not be possible to write the value of `date.max` in the database anymore: :sql:`infinity` will be stored instead. +.. _time-handling: + +Time handling +''''''''''''' + +The PostgreSQL :sql:`time` and Python `~datetime.time` types are not +fully bidirectional. + +Within PostgreSQL, the :sql:`time` type's maximum value of ``24:00:00`` is +treated as 24-hours later than the minimum value of ``00:00:00``. + + >>> cur.execute("SELECT '24:00:00'::time - '00:00:00'::time") + >>> cur.fetchone()[0] + datetime.timedelta(days=1) + +However, Python's `!time` only supports times until ``23:59:59``. +Retrieving a value of ``24:00:00`` results in a `!time` of ``00:00:00``. + + >>> cur.execute("SELECT '24:00:00'::time, '00:00:00'::time") + >>> cur.fetchone() + (datetime.time(0, 0), datetime.time(0, 0)) + + .. _adapt-list: Lists adaptation |
