We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a8bebd commit 8d08764Copy full SHA for 8d08764
1 file changed
Lib/plistlib.py
@@ -143,9 +143,17 @@ def _date_from_string(s, aware_datetime):
143
lst = []
144
for key in order:
145
val = gd[key]
146
- if val is None:
147
- break
148
- lst.append(int(val))
+ if val is not None:
+ lst.append(int(val))
+ else:
149
+ # Fill missing components with defaults: month/day -> 1, hour/minute/second -> 0
150
+ if key in ('month', 'day'):
151
+ lst.append(1)
152
+ elif key in ('hour', 'minute', 'second'):
153
+ lst.append(0)
154
155
+ # Year should never be missing due to regex
156
+ raise ValueError("Missing year in date string")
157
if aware_datetime:
158
return datetime.datetime(*lst, tzinfo=datetime.UTC)
159
return datetime.datetime(*lst)
0 commit comments