Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/19234#discussion_r139284793
--- Diff: python/pyspark/sql/types.py ---
@@ -196,7 +199,9 @@ def toInternal(self, dt):
def fromInternal(self, ts):
if ts is not None:
# using int to avoid precision loss in float
- return datetime.datetime.fromtimestamp(ts //
1000000).replace(microsecond=ts % 1000000)
+ y, m, d, hh, mm, ss, _, _, _ = (time.gmtime(ts // 1000000) if
_is_utc
+ else time.localtime(ts //
1000000))
+ return datetime.datetime(y, m, d, hh, mm, ss, ts % 1000000)
--- End diff --
I'd explain how the current change is equivalent to `fromtimestamp` in the
PR description.
https://github.com/python/cpython/blob/018d353c1c8c87767d2335cd884017c2ce12e045/Lib/datetime.py#L1425-L1458
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]