Parse numerical epoch timestamps (seconds since 1970) into a ``datetime.datetime`` in UTC using ``datetime.timedelta``. This is intended as fallback when ``fromtimestamp`` raises ``OverflowError`` or ``OSError``. :type value: float or int :param value: The Unix timestamps as number.
(value, tzinfo)
| 776 | |
| 777 | |
| 778 | def _epoch_seconds_to_datetime(value, tzinfo): |
| 779 | """Parse numerical epoch timestamps (seconds since 1970) into a |
| 780 | ``datetime.datetime`` in UTC using ``datetime.timedelta``. This is intended |
| 781 | as fallback when ``fromtimestamp`` raises ``OverflowError`` or ``OSError``. |
| 782 | |
| 783 | :type value: float or int |
| 784 | :param value: The Unix timestamps as number. |
| 785 | |
| 786 | :type tzinfo: callable |
| 787 | :param tzinfo: A ``datetime.tzinfo`` class or compatible callable. |
| 788 | """ |
| 789 | epoch_zero = datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=tzutc()) |
| 790 | epoch_zero_localized = epoch_zero.astimezone(tzinfo()) |
| 791 | return epoch_zero_localized + datetime.timedelta(seconds=value) |
| 792 | |
| 793 | |
| 794 | def _parse_timestamp_with_tzinfo(value, tzinfo): |