Skip to content

Commit d1ebf6d

Browse files
committed
Merge branch 'master' into pr/1364
2 parents 1cff969 + 3807df2 commit d1ebf6d

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

docs/src/piccolo/api_reference/index.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,43 @@ UUID
114114

115115
.. autoclass:: UUID7
116116

117+
118+
TimestampCustom
119+
~~~~~~~~~~~~~~~
120+
121+
.. autoclass:: TimestampCustom
122+
:members:
123+
124+
TimestampOffset
125+
~~~~~~~~~~~~~~~
126+
127+
.. autoclass:: TimestampOffset
128+
:members:
129+
130+
TimestampNow
131+
~~~~~~~~~~~~
132+
133+
.. autoclass:: TimestampNow
134+
:members:
135+
136+
TimestamptzCustom
137+
~~~~~~~~~~~~~~~~~
138+
139+
.. autoclass:: TimestamptzCustom
140+
:members:
141+
142+
TimestamptzOffset
143+
~~~~~~~~~~~~~~~~~
144+
145+
.. autoclass:: TimestamptzOffset
146+
:members:
147+
148+
TimestamptzNow
149+
~~~~~~~~~~~~~~
150+
151+
.. autoclass:: TimestamptzNow
152+
:members:
153+
117154
-------------------------------------------------------------------------------
118155

119156
Testing

piccolo/columns/column_types.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ def __set__(self, obj, value: Union[int, None]):
885885

886886
class Timestamp(Column):
887887
"""
888-
Used for storing datetimes. Uses the ``datetime`` type for values.
888+
Used for storing timezone naive datetimes. Uses the ``datetime`` type for
889+
values.
889890
890891
**Example**
891892
@@ -905,6 +906,12 @@ class Concert(Table):
905906
>>> await Concert.select(Concert.starts)
906907
{'starts': datetime.datetime(2050, 1, 1, 0, 0)}
907908
909+
.. note::
910+
We recommend using
911+
:class:`Timestamptz <piccolo.columns.column_types.Timestamptz>`
912+
columns if possible - having timezone information makes the timestamp
913+
unambiguous.
914+
908915
"""
909916

910917
value_type = datetime
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from .base import * # noqa
22
from .date import * # noqa
3+
from .interval import * # noqa
34
from .time import * # noqa
45
from .timestamp import * # noqa
6+
from .timestamptz import * # noqa
57
from .uuid import * # noqa

piccolo/columns/defaults/timestamp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ def python(self):
4848

4949

5050
class TimestampNow(Default):
51+
"""
52+
The current timestamp, in the local time of the machine that Python is
53+
running on.
54+
"""
55+
5156
@property
5257
def postgres(self):
5358
return "current_timestamp"

piccolo/columns/defaults/timestamptz.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def python(self):
2828

2929

3030
class TimestamptzNow(TimestampNow):
31+
"""
32+
The current timestamp in UTC.
33+
"""
34+
3135
@property
3236
def cockroach(self):
3337
return "current_timestamp"

0 commit comments

Comments
 (0)