@@ -209,10 +209,11 @@ def read(self, length: 'Optional[int]' = None, *, _read: 'bool' = True, **kwargs
209
209
_ilen = schema .incl_len
210
210
_olen = schema .orig_len
211
211
212
- if self ._nsec :
213
- _epch = _tsss + decimal .Decimal (_tsus ) / 1_000_000_000
214
- else :
215
- _epch = _tsss + decimal .Decimal (_tsus ) / 1_000_000
212
+ with decimal .localcontext (prec = 64 ):
213
+ if self ._nsec :
214
+ _epch = _tsss + decimal .Decimal (_tsus ) / 1_000_000_000
215
+ else :
216
+ _epch = _tsss + decimal .Decimal (_tsus ) / 1_000_000
216
217
_irat = _epch .as_integer_ratio ()
217
218
_time = datetime .datetime .fromtimestamp (_irat [0 ] / _irat [1 ])
218
219
@@ -403,15 +404,16 @@ def _make_timestamp(self, timestamp: 'Optional[float | Decimal | dt_type | int]'
403
404
Second and microsecond/nanosecond value of timestamp.
404
405
405
406
"""
406
- if timestamp is None :
407
- if py37 and nanosecond :
408
- timestamp = decimal .Decimal (time .time_ns ()) / 1_000_000_000
407
+ with decimal .localcontext (prec = 64 ):
408
+ if timestamp is None :
409
+ if py37 and nanosecond :
410
+ timestamp = decimal .Decimal (time .time_ns ()) / 1_000_000_000
411
+ else :
412
+ timestamp = decimal .Decimal (time .time ())
409
413
else :
410
- timestamp = decimal .Decimal (time .time ())
411
- else :
412
- if isinstance (timestamp , datetime .datetime ):
413
- timestamp = timestamp .timestamp ()
414
- timestamp = decimal .Decimal (timestamp )
414
+ if isinstance (timestamp , datetime .datetime ):
415
+ timestamp = timestamp .timestamp ()
416
+ timestamp = decimal .Decimal (timestamp )
415
417
416
418
if ts_sec is None :
417
419
ts_sec = int (timestamp )
0 commit comments