Skip to content

Commit fd30f37

Browse files
author
James William Pye
committed
Refer directly to add methods.
1 parent d4dc773 commit fd30f37

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

postgresql/types/io/stdlib_datetime.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def date_pack(x,
8484
get = date_pack_constants.get,
8585
):
8686
return get(x) or pack(x.toordinal() - offset)
87+
8788
def date_unpack(x,
8889
unpack = lib.date_unpack,
8990
offset = pg_date_offset,
@@ -104,12 +105,12 @@ def timestamp_pack(x,
104105

105106
def timestamp_unpack(seconds,
106107
timedelta = datetime.timedelta,
107-
pg_epoch_datetime = pg_epoch_datetime,
108+
relative_to = pg_epoch_datetime.__add__,
108109
):
109110
"""
110111
Create a `datetime.datetime` instance from a (seconds, microseconds) pair.
111112
"""
112-
return pg_epoch_datetime + timedelta(0, *seconds)
113+
return relative_to(timedelta(0, *seconds))
113114

114115
def timestamptz_pack(x,
115116
seconds_in_day = seconds_in_day,
@@ -124,12 +125,12 @@ def timestamptz_pack(x,
124125

125126
def timestamptz_unpack(seconds,
126127
timedelta = datetime.timedelta,
127-
pg_epoch_datetime_utc = pg_epoch_datetime_utc,
128+
relative_to = pg_epoch_datetime_utc.__add__,
128129
):
129130
"""
130131
Create a `datetime.datetime` instance from a (seconds, microseconds) pair.
131132
"""
132-
return pg_epoch_datetime_utc + timedelta(0, *seconds)
133+
return relative_to(timedelta(0, *seconds))
133134

134135
def time_pack(x):
135136
"""

0 commit comments

Comments
 (0)