Skip to content
Merged
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
Try to be consistent about use of double quotes in error messages
  • Loading branch information
pganssle committed May 5, 2022
commit 3d24a1585e01c0a68a920e0f2e095da34f9d3d84
16 changes: 8 additions & 8 deletions Lib/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def _parse_isoformat_date(dtstr):
dayno = 1
if len(dtstr) > pos:
if (dtstr[pos:pos + 1] == '-') != has_sep:
raise ValueError('Inconsistent use of dash separator')
raise ValueError("Inconsistent use of dash separator")

pos += has_sep

Expand All @@ -347,7 +347,7 @@ def _parse_isoformat_date(dtstr):
month = int(dtstr[pos:pos + 2])
pos += 2
if (dtstr[pos:pos + 1] == "-") != has_sep:
raise ValueError('Inconsistent use of dash separator')
raise ValueError("Inconsistent use of dash separator")

pos += has_sep
day = int(dtstr[pos:pos + 2])
Expand All @@ -366,7 +366,7 @@ def _parse_hh_mm_ss_ff(tstr):
pos = 0
for comp in range(0, 3):
if (len_str - pos) < 2:
raise ValueError('Incomplete time component')
raise ValueError("Incomplete time component")

time_comps[comp] = int(tstr[pos:pos+2])

Expand All @@ -380,13 +380,13 @@ def _parse_hh_mm_ss_ff(tstr):
break

if has_sep and next_char != ':':
raise ValueError('Invalid time separator: %c' % next_char)
raise ValueError("Invalid time separator: %c" % next_char)

pos += has_sep

if pos < len_str:
if tstr[pos] not in '.,':
raise ValueError('Invalid microsecond component')
raise ValueError("Invalid microsecond component")
else:
pos += 1

Expand All @@ -402,15 +402,15 @@ def _parse_hh_mm_ss_ff(tstr):
time_comps[3] *= _FRACTION_CORRECTION[to_parse-1]
if (len_remainder > to_parse
and not tstr[(pos+to_parse):].isdigit()):
raise ValueError('Non-digit values in unparsed fraction')
raise ValueError("Non-digit values in unparsed fraction")

return time_comps

def _parse_isoformat_time(tstr):
# Format supported is HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]]
len_str = len(tstr)
if len_str < 2:
raise ValueError('Isoformat time too short')
raise ValueError("Isoformat time too short")

# This is equivalent to re.search('[+-Z]', tstr), but faster
tz_pos = (tstr.find('-') + 1 or tstr.find('+') + 1 or tstr.find('Z') + 1)
Expand All @@ -434,7 +434,7 @@ def _parse_isoformat_time(tstr):
# HH:MM:SS.f+ len: 10+

if len(tzstr) in (1, 3):
raise ValueError('Malformed time zone string')
raise ValueError("Malformed time zone string")

if tzstr == 'Z':
tz_comps = (0, 0, 0, 0)
Expand Down