Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7635fe1
TEMP: Add isoformatter test
pganssle Oct 21, 2021
b9b7a03
Add support for YYYYMMDD
pganssle Oct 21, 2021
c746b96
Expand support for ISO 8601 times
pganssle Oct 21, 2021
00978f9
Add support for ISO calendar-style strings
pganssle Oct 22, 2021
c36e306
Rework how string sanitization works
pganssle Oct 22, 2021
0234cae
WIP
pganssle Nov 16, 2021
ee1a7e3
Move Isoformatter into test helper, add date/time tests
pganssle Apr 27, 2022
7d2fd33
Final location for isoformatter and strategies
pganssle Apr 27, 2022
72266c4
Working version of date.isoformat
pganssle Apr 27, 2022
8067af1
Fix failure to set an error
pganssle May 1, 2022
7b9bca5
First version with time parsing allowed
pganssle May 1, 2022
328e781
Add support for leading T in time formatters
pganssle May 1, 2022
4d0e3a9
Fix pure python separator detection in YYYYWwwd
pganssle May 1, 2022
3e600f2
Version with all tests passing
pganssle May 1, 2022
e26f06f
Migrate fromisoformat tests to their own file
pganssle May 2, 2022
1ea0cd1
Fix bug in time parsing logic
pganssle May 2, 2022
1e3577f
s/ssize_t/size_t
pganssle May 2, 2022
6422799
Add fromisoformat example tests
pganssle May 2, 2022
3d24a15
Try to be consistent about use of double quotes in error messages
pganssle May 2, 2022
661b1b0
Update documentation
pganssle May 3, 2022
1defa1d
Remove isoformatter
pganssle May 3, 2022
75de7a4
Update out-of-date comment
pganssle May 3, 2022
07ee419
Only one space
pganssle May 3, 2022
3d0fb7a
Explicitly handle 0-length tzstr
pganssle May 3, 2022
cc8c737
Raise exceptions from None
pganssle May 3, 2022
31bf63e
Add test cases around week 53
pganssle May 3, 2022
5bfb3fc
Add examples around week 53
pganssle May 3, 2022
4879a47
Update docstrings
pganssle May 3, 2022
3cd657f
Add news entry
pganssle May 3, 2022
763d5bb
Add what's new entry
pganssle May 3, 2022
3a06505
Be consistent about ISO 8601
pganssle May 3, 2022
e643f02
Change name of isoformat separator detection function
pganssle May 5, 2022
5046809
Remove 'mode' logic and update comments
pganssle May 5, 2022
90093bf
Fix segfault case
pganssle May 5, 2022
6fc8157
Explicitly cast signed to unsigned
pganssle May 5, 2022
d9a766b
Document that ordinal dates are not supported
pganssle May 5, 2022
04ed787
Remove dead code
pganssle May 5, 2022
6da3e90
Various fixes
pganssle May 5, 2022
92cc0be
Fix example
pganssle May 5, 2022
bec0bee
Add example for time.fromisoformat
pganssle May 5, 2022
aad6011
Fix trailing colon
pganssle May 5, 2022
a33d776
Remove fromisoformat property test
pganssle May 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Be consistent about ISO 8601
  • Loading branch information
pganssle committed May 5, 2022
commit 3a06505549c75127d619874f3b3ed0f6aed125d9
6 changes: 3 additions & 3 deletions Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ Other constructors, all class methods:
.. classmethod:: date.fromisoformat(date_string)

Return a :class:`date` corresponding to a *date_string* given in any valid
ISO-8601 format:
ISO 8601 format:

>>> from datetime import date
>>> date.fromisoformat('2019-12-04')
Expand Down Expand Up @@ -995,7 +995,7 @@ Other constructors, all class methods:
.. classmethod:: datetime.fromisoformat(date_string)

Return a :class:`.datetime` corresponding to a *date_string* in any valid
ISO-8601 format, with the following exceptions:
ISO 8601 format, with the following exceptions:

1. Time zone offsets may have fractional seconds.
2. The `T` separator may be replaced by any single unicode character.
Expand Down Expand Up @@ -1768,7 +1768,7 @@ Other constructor:
.. classmethod:: time.fromisoformat(time_string)

Return a :class:`.time` corresponding to a *time_string* in any valid
ISO-8601 format, with the following exceptions:
ISO 8601 format, with the following exceptions:

1. Time zone offsets may have fractional seconds.
2. The leading `T`, normally required in cases where there may be ambiguity between
Expand Down
2 changes: 1 addition & 1 deletion Lib/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ def fromisoformat(cls, time_string):
if not isinstance(time_string, str):
raise TypeError('fromisoformat: argument must be str')

# The spec actually requires that time-only ISO-8601 strings start with
# The spec actually requires that time-only ISO 8601 strings start with
# T, but the extended format allows this to be omitted as long as there
# is no ambiguity with date strings.
time_string = time_string.removeprefix('T')
Expand Down
4 changes: 2 additions & 2 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4640,7 +4640,7 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
goto invalid_string_error;
}

// The spec actually requires that time-only ISO-8601 strings start with
// The spec actually requires that time-only ISO 8601 strings start with
// T, but the extended format allows this to be omitted as long as there
// is no ambiguity with date strings.
if (*p == 'T') {
Expand Down Expand Up @@ -5269,7 +5269,7 @@ static PyObject *
_sanitize_isoformat_str(PyObject *dtstr)
{
Py_ssize_t len = PyUnicode_GetLength(dtstr);
if (len < 7) { // All valid ISO8601 strings are at least 7 characters long
if (len < 7) { // All valid ISO 8601 strings are at least 7 characters long
return NULL;
}

Expand Down