[issue46660] datetime.datetime.fromtimestamp
New submission from Sam Roberts : Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 datetime.fromtimestamp() fails for naive-datetime values prior to the start of the epoch, but for some reason works properly for aware-datetime values prior to the start of the epoch. This is at least inconsistent, but seems like a bug. Negative timestamps for dates prior to the start of the epoch are used by yahoo finance and in the yfinance module. >>> import datetime >>> start = int(datetime.datetime(1962, 1, 31, >>> tzinfo=datetime.timezone.utc).timestamp()) >>> start -249868800 >>> start = int(datetime.datetime(1962, 1, 31).timestamp()) Traceback (most recent call last): File "", line 1, in start = int(datetime.datetime(1962, 1, 31).timestamp()) OSError: [Errno 22] Invalid argument -- components: Library (Lib) messages: 412649 nosy: smrpy priority: normal severity: normal status: open title: datetime.datetime.fromtimestamp type: behavior versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue46660> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46660] datetime.fromtimestamp() fails for naive-datetime values prior to the start of the epoch
Change by Sam Roberts : -- title: datetime.datetime.fromtimestamp -> datetime.fromtimestamp() fails for naive-datetime values prior to the start of the epoch ___ Python tracker <https://bugs.python.org/issue46660> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46660] datetime.timestamp() fails for naive-datetime values prior to the start of the epoch
Sam Roberts added the comment: the first sentence should have read: datetime.timestamp() fails for naive-datetime values prior to the start of the epoch, but for some reason works properly for aware-datetime values prior to the start of the epoch. -- title: datetime.fromtimestamp() fails for naive-datetime values prior to the start of the epoch -> datetime.timestamp() fails for naive-datetime values prior to the start of the epoch ___ Python tracker <https://bugs.python.org/issue46660> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46660] datetime.timestamp() fails for naive-datetime values prior to the start of the epoch
Sam Roberts added the comment: this seems like an expected discrepancy because of a difference in the mechanism used for aware datatimes vs. naive datetimes, although I'm not sure I understand why the computation with naive datetimes uses the mktime() function rather than invoking datetime.timedelta.total_seconds() on a datetime difference. -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue46660> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46660] datetime.timestamp() fails for naive-datetime values prior to the start of the epoch
Change by Sam Roberts : -- resolution: -> not a bug ___ Python tracker <https://bugs.python.org/issue46660> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com