Commit Graph

16 Commits

Author SHA1 Message Date
Nice Zombies 9968caa0cc
gh-41431: Add `datetime.time.strptime()` and `datetime.date.strptime()` (#120752)
* Python implementation

* C implementation

* Test `date.strptime`

* Test `time.strptime`

* 📜🤖 Added by blurb_it.

* Update whatsnew

* Update documentation

* Add leap year note

* Update 2024-06-19-19-53-42.gh-issue-41431.gnkUc5.rst

* Apply suggestions from code review

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Remove parentheses

* Use helper function

* Remove bad return

* Link to github issue

* Fix directive

* Apply suggestions from code review

Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>

* Fix test cases

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2024-09-25 14:43:58 -07:00
TizzySaurus b0c6cf5f17
gh-102450: Add ISO-8601 alternative for midnight to `fromisoformat()` calls. (#105856)
* Add NEWS.d entry

* Allow ISO-8601 24:00 alternative to midnight on datetime.time.fromisoformat()

* Allow ISO-8601 24:00 alternative to midnight on datetime.datetime.fromisoformat()

* Add NEWS.d entry

* Improve error message when hour is 24 and minute/second/microsecond is not 0

* Add tests for 24:00 fromisoformat

* Remove duplicate call to days_in_month() by storing in variable

* Add Python implementation

* Fix Lint

* Fix differing error msg in datetime.fromisoformat implementations when 24hrs has non-zero time component(s)

* Fix using time components inside tzinfo in Python implementation

* Don't parse tzinfo in C implementation when invalid iso midnight

* Remove duplicated variable in datetime test assertion line

* Add self to acknowledgements

* Remove duplicate NEWS entry

* Linting

* Add missing test case for when wrapping the year makes it invalid (too large)
2024-09-25 14:32:51 -07:00
Adam Turner 93b61bc124
gh-123843: Remove broken links to the Zope DateTimeWiki (#123846)
Co-authored-by: Conrad Bhuiyan-Volkoff <hi@cbv.im>
2024-09-08 22:39:23 -04:00
blhsing 126910edba
gh-122272: Guarantee specifiers %F and %C for datetime.strftime to be 0-padded (GH-122436) 2024-08-23 18:45:03 +03:00
blhsing 6d34938dc8
gh-120713: Normalize year with century for datetime.strftime (GH-120820) 2024-06-29 09:32:42 +03:00
Kirill Podoprigora 34f5ae69fe
gh-120268: Prohibit passing ``None`` to ``_pydatetime.date.fromtimestamp`` (#120269)
This makes the pure Python implementation consistent with the C implementation.
2024-06-08 16:45:57 -04:00
Serhiy Storchaka b104360788
gh-49766: Make date-datetime comparison more symmetric and flexible (GH-114760)
Now the special comparison methods like `__eq__` and `__lt__` return
NotImplemented if one of comparands is date and other is datetime
instead of ignoring the time part and the time zone or forcefully
return "not equal" or raise TypeError.

It makes comparison of date and datetime subclasses more symmetric
and allows to change the default behavior by overriding
the special comparison methods in subclasses.

It is now the same as if date and datetime was independent classes.
2024-02-11 13:06:43 +02:00
Serhiy Storchaka dc4cd2c9ba
gh-106392: Fix inconsistency in deprecation warnings in datetime module (GH-114761) 2024-01-30 22:15:33 +00:00
Mariusz Felisiak 456e274578
gh-112451: Prohibit subclassing of datetime.timezone. (#114190)
This is consistent with C-extension datetime.timezone.
2024-01-26 09:33:13 +01:00
James Hilton-Balfe 7d57288f6d
gh-109495: Remove unused slots from the Python implementation of datetime (GH-109494) 2023-09-29 19:57:32 +03:00
Christopher Yeh 5eec58a9e5
Fix date.__repr__() docstring (#109422) 2023-09-15 15:05:19 +02:00
Mikhail Samylov 60a9eea3f5
Docs: Fix typo in datetime.tzinfo docstring (#107257)
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-06 21:29:46 +00:00
Serhiy Storchaka 6f3c138dfa
gh-108751: Add copy.replace() function (GH-108752)
It creates a modified copy of an object by calling the object's
__replace__() method.

It is a generalization of dataclasses.replace(), named tuple's _replace()
method and replace() methods in various classes, and supports all these
stdlib classes.
2023-09-06 23:55:42 +03:00
William Andrea d5c5d4bfd3
gh-106392: Fix inconsistency in deprecation warnings (#106436)
They used "datetime" to refer to both the object and the module.
2023-09-01 22:31:21 +00:00
Paul Ganssle 0a5cd984b2 GH-84976: Re-introduce `datetime.py` and fix reprs
Without the change to the reprs, pure-python classes would have a repr
of `datetime._pydatetime.time`, etc.
2023-05-03 03:09:45 -06:00
Paul Ganssle 65c4a2b326 GH-84976: Move Lib/datetime.py to Lib/_pydatetime
This breaks the tests, but we are keeping it as a separate commit so
that the move operation and editing of the moved files are separate, for
a cleaner history.
2023-05-03 03:09:45 -06:00