mistercrunch commented on code in PR #34514:
URL: https://github.com/apache/superset/pull/34514#discussion_r2249434401


##########
superset/utils/json.py:
##########
@@ -155,9 +160,27 @@ def json_int_dttm_ser(obj: Any) -> Any:
     """
 
     if isinstance(obj, (datetime, pd.Timestamp)):
+        # Check if datetime is within JavaScript's safe date range
+        # If not, return ISO string instead of epoch milliseconds
+        if isinstance(obj, pd.Timestamp):
+            dttm = obj.to_pydatetime()
+        else:
+            dttm = obj
+
+        # Remove timezone info for comparison
+        dttm_no_tz = dttm.replace(tzinfo=None) if dttm.tzinfo else dttm
+
+        if dttm_no_tz < JS_DATE_RANGE_MIN or dttm_no_tz > JS_DATE_RANGE_MAX:
+            # Return ISO string for dates outside JavaScript's safe range
+            return obj.isoformat()
+
         return datetime_to_epoch(obj)
 
     if isinstance(obj, date):
+        # Check if date is within JavaScript's safe date range

Review Comment:
   Oh interesting, it would have been an issue before this PR, but does 
`date.date` not have a tzinfo like `date.datetime`? Seem we should apply this 
consistently ...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to