-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptime patterns #127552
Comments
@brettcannon git blame says you added this comment in 2003 in commit 474335c |
Actually that comment was moved in 2003, but it came into existence in Dec 2002, so just shy of 22 years ago. 😅 Anyway, since the implementation has required 4 digits since my code was first committed in July 2002, I think it's safe to say that the comment is no longer necessary. 😁 @bombs-kim if you want to do a PR then go for it! Otherwise I'm assigning this to myself not to forget about it. |
Glibc implementation of |
@brettcannon @serhiy-storchaka |
…datetime.strptime patterns (#127590) The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit).
…Y’ in datetime.strptime patterns (pythonGH-127590) The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit). (cherry picked from commit 51cfa56) Co-authored-by: Beomsoo Kim <beoms424@gmail.com>
…Y’ in datetime.strptime patterns (pythonGH-127590) The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit). (cherry picked from commit 51cfa56) Co-authored-by: Beomsoo Kim <beoms424@gmail.com>
…‘Y’ in datetime.strptime patterns (GH-127590) GH-127650) gh-127552: Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptime patterns (GH-127590) The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit). (cherry picked from commit 51cfa56) Co-authored-by: Beomsoo Kim <beoms424@gmail.com>
…‘Y’ in datetime.strptime patterns (GH-127590) (#127649) gh-127552: Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptime patterns (GH-127590) The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit). (cherry picked from commit 51cfa56) Co-authored-by: Beomsoo Kim <beoms424@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
found a comment in _strptime.py that I believe is unnecessary and potentially outdated:
cpython/Lib/_strptime.py
Line 304 in 8c3fd1f
The comment reads:
# XXX: Does 'Y' need to worry about having less or more than 4 digits?
This question seems irrelevant based on the current documentation and implementation standards. Here are my reasons:
Python documentation specifies a 4-digit restriction
The Python documentation for datetime.strptime states: The
strptime()
method can parse years in the full [1, 9999] range, but years < 1000 must be zero-filled to 4-digit width. This makes it clear that Y is explicitly designed for 4-digit years only.Supporting more than 4 digits is impractical
Years with 5 or more digits cannot be represented in the resulting datetime type. The datetime implementation enforces the [1, 9999] year range, which inherently limits support for larger year values.
Support for fewer than 4 digits tends to not standard-compliant
Some popular specifications expect a minimum of 4 digits for representing a year:
Given these points, I propose removing the comment as it no longer adds value and could potentially confuse contributors or maintainers. If desired, I can submit a pull request to address this.
Linked PRs
The text was updated successfully, but these errors were encountered: