@@ -12,47 +12,47 @@ date_from_ordinal = datetime.date.fromordinal
1212timedelta = datetime.timedelta
1313
1414pg_epoch_datetime = datetime.datetime(2000 , 1 , 1 )
15- cdef long pg_epoch_datetime_ts = \
15+ cdef int32_t pg_epoch_datetime_ts = \
1616 cpython.PyLong_AsLong(int (pg_epoch_datetime.timestamp()))
1717
1818pg_epoch_datetime_utc = datetime.datetime(2000 , 1 , 1 , tzinfo = utc)
19- cdef long pg_epoch_datetime_utc_ts = \
19+ cdef int32_t pg_epoch_datetime_utc_ts = \
2020 cpython.PyLong_AsLong(pg_epoch_datetime_utc.timestamp())
2121
2222pg_epoch_date = datetime.date(2000 , 1 , 1 )
23- cdef long pg_date_offset_ord = \
23+ cdef int32_t pg_date_offset_ord = \
2424 cpython.PyLong_AsLong(pg_epoch_date.toordinal())
2525
2626# Binary representations of infinity for datetimes.
27- cdef long long pg_time64_infinity = 0x7fffffffffffffff
28- cdef long long pg_time64_negative_infinity = 0x8000000000000000
27+ cdef int64_t pg_time64_infinity = 0x7fffffffffffffff
28+ cdef int64_t pg_time64_negative_infinity = 0x8000000000000000
2929cdef int32_t pg_date_infinity = 0x7fffffff
3030cdef int32_t pg_date_negative_infinity = 0x80000000
3131
3232infinity_datetime = datetime.datetime(
3333 datetime.MAXYEAR, 12 , 31 , 23 , 59 , 59 , 999999 )
3434
35- cdef long infinity_datetime_ord = cpython.PyLong_AsLong(
35+ cdef int32_t infinity_datetime_ord = cpython.PyLong_AsLong(
3636 infinity_datetime.toordinal())
3737
3838cdef int64_t infinity_datetime_ts = 252455615999999999
3939
4040negative_infinity_datetime = datetime.datetime(
4141 datetime.MINYEAR, 1 , 1 , 0 , 0 , 0 , 0 )
4242
43- cdef long negative_infinity_datetime_ord = cpython.PyLong_AsLong(
43+ cdef int32_t negative_infinity_datetime_ord = cpython.PyLong_AsLong(
4444 negative_infinity_datetime.toordinal())
4545
4646cdef int64_t negative_infinity_datetime_ts = - 63082281600000000
4747
4848infinity_date = datetime.date(datetime.MAXYEAR, 12 , 31 )
4949
50- cdef long infinity_date_ord = cpython.PyLong_AsLong(
50+ cdef int32_t infinity_date_ord = cpython.PyLong_AsLong(
5151 infinity_date.toordinal())
5252
5353negative_infinity_date = datetime.date(datetime.MINYEAR, 1 , 1 )
5454
55- cdef long negative_infinity_date_ord = cpython.PyLong_AsLong(
55+ cdef int32_t negative_infinity_date_ord = cpython.PyLong_AsLong(
5656 negative_infinity_date.toordinal())
5757
5858
@@ -117,7 +117,7 @@ cdef date_decode(ConnectionSettings settings, FastReadBuffer buf):
117117cdef timestamp_encode(ConnectionSettings settings, WriteBuffer buf, obj):
118118 delta = obj - pg_epoch_datetime
119119 cdef:
120- int64_t seconds = cpython.PyLong_AsLong (delta.days) * 86400 + \
120+ int64_t seconds = cpython.PyLong_AsLongLong (delta.days) * 86400 + \
121121 cpython.PyLong_AsLong(delta.seconds)
122122 int32_t microseconds = cpython.PyLong_AsLong(delta.microseconds)
123123
@@ -154,7 +154,7 @@ cdef timestamptz_encode(ConnectionSettings settings, WriteBuffer buf, obj):
154154
155155 delta = obj.astimezone(utc) - pg_epoch_datetime_utc
156156 cdef:
157- int64_t seconds = cpython.PyLong_AsLong (delta.days) * 86400 + \
157+ int64_t seconds = cpython.PyLong_AsLongLong (delta.days) * 86400 + \
158158 cpython.PyLong_AsLong(delta.seconds)
159159 int32_t microseconds = cpython.PyLong_AsLong(delta.microseconds)
160160
0 commit comments