@@ -116,15 +116,6 @@ def null_send(v) -> bytes:
116116 return NULL
117117
118118
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-
128119# data is 64-bit integer representing microseconds since 2000-01-01
129120def timestamp_recv_integer (data : bytes , offset : int , length : int ) -> typing .Union [Datetime , str , float ]:
130121 micros : float = q_unpack (data , offset )[0 ]
@@ -144,23 +135,12 @@ def timestamp_send_integer(v: Datetime) -> bytes:
144135 return q_pack (int ((timegm (v .timetuple ()) - EPOCH_SECONDS ) * 1e6 ) + v .microsecond )
145136
146137
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-
152138def timestamptz_send_integer (v : Datetime ) -> bytes :
153139 # timestamps should be sent as UTC. If they have zone info,
154140 # convert them.
155141 return timestamp_send_integer (v .astimezone (Timezone .utc ).replace (tzinfo = None ))
156142
157143
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-
164144# return a timezone-aware datetime instance if we're reading from a
165145# "timestamp with timezone" type. The timezone returned will always be
166146# 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
193173# return typing.cast(bytes, qii_pack(microseconds, v.days, months))
194174
195175
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-
211176glbls : typing .Dict [str , type ] = {"Decimal" : Decimal }
212177trans_tab = dict (zip (map (ord , "{}" ), "[]" ))
213178
@@ -236,15 +201,6 @@ def numeric_in(data: bytes, offset: int, length: int) -> Decimal:
236201# return UUID(bytes=data[offset:offset+length])
237202
238203
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-
248204# def interval_recv_integer(data: bytes, offset: int, length: int) -> typing.Union[Timedelta, Interval]:
249205# microseconds, days, months = typing.cast(
250206# typing.Tuple[int, ...], qii_unpack(data, offset)
@@ -346,8 +302,8 @@ def date_in(data: bytes, offset: int, length: int):
346302 1043 : (FC_BINARY , text_recv ), # VARCHAR type
347303 1082 : (FC_TEXT , date_in ), # date
348304 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 ),
351307 # 1186: (FC_BINARY, interval_recv_integer),
352308 # 1231: (FC_TEXT, array_in), # NUMERIC[]
353309 # 1263: (FC_BINARY, array_recv), # cstring[]
0 commit comments