@@ -116,15 +116,6 @@ def null_send(v) -> bytes:
116
116
return NULL
117
117
118
118
119
- # data is double-precision float representing seconds since 2000-01-01
120
- def timestamp_recv_float (data : bytes , offset : int , length : int ) -> Datetime :
121
- return Datetime .utcfromtimestamp (EPOCH_SECONDS + d_unpack (data , offset )[0 ])
122
-
123
-
124
- def timestamptz_recv_float (data : bytes , offset : int , length : int ) -> Datetime :
125
- return timestamp_recv_float (data , offset , length ).replace (tzinfo = Timezone .utc )
126
-
127
-
128
119
# data is 64-bit integer representing microseconds since 2000-01-01
129
120
def timestamp_recv_integer (data : bytes , offset : int , length : int ) -> typing .Union [Datetime , str , float ]:
130
121
micros : float = q_unpack (data , offset )[0 ]
@@ -144,23 +135,12 @@ def timestamp_send_integer(v: Datetime) -> bytes:
144
135
return q_pack (int ((timegm (v .timetuple ()) - EPOCH_SECONDS ) * 1e6 ) + v .microsecond )
145
136
146
137
147
- # data is double-precision float representing seconds since 2000-01-01
148
- def timestamp_send_float (v : Datetime ) -> bytes :
149
- return d_pack (timegm (v .timetuple ()) + v .microsecond / 1e6 - EPOCH_SECONDS )
150
-
151
-
152
138
def timestamptz_send_integer (v : Datetime ) -> bytes :
153
139
# timestamps should be sent as UTC. If they have zone info,
154
140
# convert them.
155
141
return timestamp_send_integer (v .astimezone (Timezone .utc ).replace (tzinfo = None ))
156
142
157
143
158
- def timestamptz_send_float (v : Datetime ) -> bytes :
159
- # timestamps should be sent as UTC. If they have zone info,
160
- # convert them.
161
- return timestamp_send_float (v .astimezone (Timezone .utc ).replace (tzinfo = None ))
162
-
163
-
164
144
# return a timezone-aware datetime instance if we're reading from a
165
145
# "timestamp with timezone" type. The timezone returned will always be
166
146
# UTC, but providing that additional information can permit conversion
@@ -193,21 +173,6 @@ def timestamptz_recv_integer(data: bytes, offset: int, length: int) -> typing.Un
193
173
# return typing.cast(bytes, qii_pack(microseconds, v.days, months))
194
174
195
175
196
- # def interval_send_float(v: typing.Union[Interval, Timedelta]) -> bytes:
197
- # seconds: float = v.microseconds / 1000.0 / 1000.0
198
- # try:
199
- # seconds += v.seconds # type: ignore
200
- # except AttributeError:
201
- # pass
202
- #
203
- # try:
204
- # months: int = v.months # type: ignore
205
- # except AttributeError:
206
- # months = 0
207
- #
208
- # return typing.cast(bytes, dii_pack(seconds, v.days, months))
209
-
210
-
211
176
glbls : typing .Dict [str , type ] = {"Decimal" : Decimal }
212
177
trans_tab = dict (zip (map (ord , "{}" ), "[]" ))
213
178
@@ -236,15 +201,6 @@ def numeric_in(data: bytes, offset: int, length: int) -> Decimal:
236
201
# return UUID(bytes=data[offset:offset+length])
237
202
238
203
239
- # def interval_recv_float(data: bytes, offset: int, length: int) -> typing.Union[Timedelta, Interval]:
240
- # seconds, days, months = typing.cast(typing.Tuple[int, ...], dii_unpack(data, offset))
241
- # if months == 0:
242
- # secs, microseconds = divmod(seconds, 1e6)
243
- # return Timedelta(days, secs, microseconds)
244
- # else:
245
- # return Interval(int(seconds * 1000 * 1000), days, months)
246
-
247
-
248
204
# def interval_recv_integer(data: bytes, offset: int, length: int) -> typing.Union[Timedelta, Interval]:
249
205
# microseconds, days, months = typing.cast(
250
206
# typing.Tuple[int, ...], qii_unpack(data, offset)
@@ -346,8 +302,8 @@ def date_in(data: bytes, offset: int, length: int):
346
302
1043 : (FC_BINARY , text_recv ), # VARCHAR type
347
303
1082 : (FC_TEXT , date_in ), # date
348
304
1083 : (FC_TEXT , time_in ),
349
- 1114 : (FC_BINARY , timestamp_recv_float ), # timestamp w/ tz
350
- 1184 : (FC_BINARY , timestamptz_recv_float ),
305
+ 1114 : (FC_BINARY , timestamp_recv_integer ), # timestamp w/ tz
306
+ 1184 : (FC_BINARY , timestamptz_recv_integer ),
351
307
# 1186: (FC_BINARY, interval_recv_integer),
352
308
# 1231: (FC_TEXT, array_in), # NUMERIC[]
353
309
# 1263: (FC_BINARY, array_recv), # cstring[]
0 commit comments