Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change datetime.MINYEAR to allow for negative years #82173

Closed
SamWainwright mannequin opened this issue Aug 31, 2019 · 3 comments
Closed

Change datetime.MINYEAR to allow for negative years #82173

SamWainwright mannequin opened this issue Aug 31, 2019 · 3 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@SamWainwright
Copy link
Mannequin

SamWainwright mannequin commented Aug 31, 2019

BPO 37992
Nosy @tim-one, @abalkin, @pganssle

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2019-09-06.22:01:49.896>
created_at = <Date 2019-08-31.01:20:47.314>
labels = ['type-feature', 'library', '3.9']
title = 'Change datetime.MINYEAR to allow for negative years'
updated_at = <Date 2019-09-06.22:01:49.890>
user = 'https://bugs.python.org/SamWainwright'

bugs.python.org fields:

activity = <Date 2019-09-06.22:01:49.890>
actor = 'terry.reedy'
assignee = 'none'
closed = True
closed_date = <Date 2019-09-06.22:01:49.896>
closer = 'terry.reedy'
components = ['Library (Lib)']
creation = <Date 2019-08-31.01:20:47.314>
creator = 'Sam Wainwright'
dependencies = []
files = []
hgrepos = []
issue_num = 37992
keywords = []
message_count = 3.0
messages = ['350904', '350929', '350931']
nosy_count = 4.0
nosy_names = ['tim.peters', 'belopolsky', 'p-ganssle', 'Sam Wainwright']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue37992'
versions = ['Python 3.9']

@SamWainwright SamWainwright mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Aug 31, 2019
@SamWainwright
Copy link
Mannequin Author

SamWainwright mannequin commented Aug 31, 2019

The value of datetime.MINYEAR (1) seems arbitrarily restrictive. There are plenty of reasons why users of the standard library might want to work with negative years. Workarounds involving things like astropy don't work in all cases, particularly when you're working with other third-party libraries that use python dates internally and forking them is a hassle.

@pganssle
Copy link
Member

This is only a semi-arbitrary restriction. Realistically, datetime is not a particularly good way to represent times much older than the 17th or 18th century (and if you're using time zones, it gets increasingly inaccurate as you go further back from 1970 or the further in the future you go from the current time). Generally, I think the choice to keep it to positive dates is due to a combination of the fact that 1. it introduces a lot more edge cases (there's no year 0, for example) 2. it may invalidate otherwise perfectly acceptable assumptions that people have made in code about the sign of the component values and 3. it would be a rarely used feature of dubious utility. I am not sure that adding this feature would be worth the support burden it would bring.

There was a discussion about this on the discourse in the past, there wasn't an obvious consensus that it would never happen, but I would not say that there was much support for the idea: https://discuss.python.org/t/bc-date-support/582/2

@tim-one
Copy link
Member

tim-one commented Aug 31, 2019

This just isn't going to happen. There's no agreement to be had. For example, the proleptic Gregorian calendar _does_ have a "year 0", and so also does ISO 8601.

Version 1.0 of the XML schema spec did not have a year 0, but _claimed_ to be compatible with ISO 8601 - which it wasn't in this respect. So version 1.1 added year 0, despite then being incompatible with version 1.0 of itself in this respect[1].

I am not sure that adding this feature would be worth
the support burden it would bring.

I am: it wouldn't ;-)

[1] https://en.wikipedia.org/wiki/Astronomical_year_numbering

@terryjreedy terryjreedy added 3.9 only security fixes and removed 3.7 (EOL) end of life labels Sep 6, 2019
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants