[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2021-07-08 Thread Andrei Kulakov
Andrei Kulakov added the comment: Perhaps min and max should be moved 24 hours up and down respectively? This would make their names more accurately reflect valid range of the class and also allow them to be used as effective -inf +inf. -- nosy: +andrei.avk

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2021-01-31 Thread Chris Jerdonek
Change by Chris Jerdonek : -- nosy: +chris.jerdonek ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2021-01-29 Thread Sam Kagan
Sam Kagan added the comment: I encountered this issue in Python 3.8. I consider it to be a bug because it's an instance of a class-defined constant (datetime.min) not working with a method of that class (timestamp) when all other values that the class could take work with the method AND the

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > It still seems like this shouldn't give an error (especially when the > timezone of the local machine is UTC) This is the part where I agree with you. I suspect the error in the UTC case is an artifact of PEP 495 fold calculations that require

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: BTW, I was originally against introducing .timestamp() method and this issue illustrates why it is problematic: people use it without understanding what it does. If you want the distance between datetime.min and datetime(1970,1,1) in seconds - compute

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It your use case, the input "0001-01-01T00:00:00" was in what timezone? I suspect what you want is >>> datetime.min.replace(tzinfo=timezone.utc).timestamp() -62135596800.0 And not -62135658000.0. If you work with naive datetimes and just want to

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread Dave Johansen
Dave Johansen added the comment: Ok, so I understand the issue now. `timestamp()` for naive datetime instances applies the local timezone offset ( https://docs.python.org/3.6/library/datetime.html#datetime.datetime.timestamp ). This is surprising because naive datetime instances usually are

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread Dave Johansen
Dave Johansen added the comment: The use case was parsing user input of ISO 8601 date strings and converting them to UNIX epochs. The input "0001-01-01T00:00:00" is valid, parses to a valid `datetime` and it seems like a reasonable expectation that all of the functions should work on a valid

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On the second thought, a reasonable design can use datetime.min/max as placeholders for unknown times far in the past/future compensating for the lack datetime ±inf. In this use case, it may be annoying to see errors from timestamp() instead of some

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The question is whether -62135658000.0 is the "correct" or even meaningful value: >>> datetime.utcfromtimestamp(-62135658000.0) Traceback (most recent call last): File "", line 1, in ValueError: year is out of range (I ran the above in Python 2.7 to

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread Dave Johansen
Dave Johansen added the comment: That's a valid `datetime` (i.e. within the min and max values) and `tzinfo` is `None` so I think it's completely reasonable to assume that `timestamp()` will return the correct value. -- ___ Python tracker

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread STINNER Victor
Changes by STINNER Victor : -- title: min date can't be converted to timestamp -> datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp ___ Python tracker

[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

2017-08-16 Thread STINNER Victor
STINNER Victor added the comment: Note: My change was the commit 5b804b2fb0eaa2bacb4afcfe4cfa85b31475e87f which prevented a crash, bpo-29100. -- ___ Python tracker