(timestamp: pd.Timestamp)
| 296 | |
| 297 | |
| 298 | def _cast_timestamp_to_coarsest_resolution(timestamp: pd.Timestamp) -> pd.Timestamp: |
| 299 | # Cast timestamp to the coarsest resolution that can be used without |
| 300 | # changing its value. If provided a string, the pandas.Timestamp |
| 301 | # constructor used to automatically infer this from the resolution of the |
| 302 | # string, but this behavior was changed in pandas-dev/pandas#62801. This |
| 303 | # function allows us to approximately restore the old behavior in a way |
| 304 | # that is perhaps more consistent with how we infer the resolution of the |
| 305 | # data values themselves. |
| 306 | for unit in _ORDERED_PANDAS_TIME_RESOLUTIONS: |
| 307 | coarsest_timestamp = timestamp.as_unit(unit) |
| 308 | if coarsest_timestamp == timestamp: |
| 309 | return coarsest_timestamp |
| 310 | return timestamp |
| 311 | |
| 312 | |
| 313 | def _unpack_time_unit_and_ref_date( |
no outgoing calls
no test coverage detected
searching dependent graphs…