MCPcopy Create free account
hub / github.com/aws/aws-cli / _epoch_seconds_to_datetime

Function _epoch_seconds_to_datetime

awscli/botocore/utils.py:778–791  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

776
777
778def _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
794def _parse_timestamp_with_tzinfo(value, tzinfo):

Callers 1

parse_timestampFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected