@@ -12,47 +12,47 @@ date_from_ordinal = datetime.date.fromordinal
12
12
timedelta = datetime.timedelta
13
13
14
14
pg_epoch_datetime = datetime.datetime(2000 , 1 , 1 )
15
- cdef long pg_epoch_datetime_ts = \
15
+ cdef int32_t pg_epoch_datetime_ts = \
16
16
cpython.PyLong_AsLong(int (pg_epoch_datetime.timestamp()))
17
17
18
18
pg_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 = \
20
20
cpython.PyLong_AsLong(pg_epoch_datetime_utc.timestamp())
21
21
22
22
pg_epoch_date = datetime.date(2000 , 1 , 1 )
23
- cdef long pg_date_offset_ord = \
23
+ cdef int32_t pg_date_offset_ord = \
24
24
cpython.PyLong_AsLong(pg_epoch_date.toordinal())
25
25
26
26
# 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
29
29
cdef int32_t pg_date_infinity = 0x7fffffff
30
30
cdef int32_t pg_date_negative_infinity = 0x80000000
31
31
32
32
infinity_datetime = datetime.datetime(
33
33
datetime.MAXYEAR, 12 , 31 , 23 , 59 , 59 , 999999 )
34
34
35
- cdef long infinity_datetime_ord = cpython.PyLong_AsLong(
35
+ cdef int32_t infinity_datetime_ord = cpython.PyLong_AsLong(
36
36
infinity_datetime.toordinal())
37
37
38
38
cdef int64_t infinity_datetime_ts = 252455615999999999
39
39
40
40
negative_infinity_datetime = datetime.datetime(
41
41
datetime.MINYEAR, 1 , 1 , 0 , 0 , 0 , 0 )
42
42
43
- cdef long negative_infinity_datetime_ord = cpython.PyLong_AsLong(
43
+ cdef int32_t negative_infinity_datetime_ord = cpython.PyLong_AsLong(
44
44
negative_infinity_datetime.toordinal())
45
45
46
46
cdef int64_t negative_infinity_datetime_ts = - 63082281600000000
47
47
48
48
infinity_date = datetime.date(datetime.MAXYEAR, 12 , 31 )
49
49
50
- cdef long infinity_date_ord = cpython.PyLong_AsLong(
50
+ cdef int32_t infinity_date_ord = cpython.PyLong_AsLong(
51
51
infinity_date.toordinal())
52
52
53
53
negative_infinity_date = datetime.date(datetime.MINYEAR, 1 , 1 )
54
54
55
- cdef long negative_infinity_date_ord = cpython.PyLong_AsLong(
55
+ cdef int32_t negative_infinity_date_ord = cpython.PyLong_AsLong(
56
56
negative_infinity_date.toordinal())
57
57
58
58
@@ -117,7 +117,7 @@ cdef date_decode(ConnectionSettings settings, FastReadBuffer buf):
117
117
cdef timestamp_encode(ConnectionSettings settings, WriteBuffer buf, obj):
118
118
delta = obj - pg_epoch_datetime
119
119
cdef:
120
- int64_t seconds = cpython.PyLong_AsLong (delta.days) * 86400 + \
120
+ int64_t seconds = cpython.PyLong_AsLongLong (delta.days) * 86400 + \
121
121
cpython.PyLong_AsLong(delta.seconds)
122
122
int32_t microseconds = cpython.PyLong_AsLong(delta.microseconds)
123
123
@@ -154,7 +154,7 @@ cdef timestamptz_encode(ConnectionSettings settings, WriteBuffer buf, obj):
154
154
155
155
delta = obj.astimezone(utc) - pg_epoch_datetime_utc
156
156
cdef:
157
- int64_t seconds = cpython.PyLong_AsLong (delta.days) * 86400 + \
157
+ int64_t seconds = cpython.PyLong_AsLongLong (delta.days) * 86400 + \
158
158
cpython.PyLong_AsLong(delta.seconds)
159
159
int32_t microseconds = cpython.PyLong_AsLong(delta.microseconds)
160
160
0 commit comments