Skip to content

Commit 23f290f

Browse files
committed
Fix ISO week dates not being parsed properly in from_format()
1 parent 19d43e8 commit 23f290f

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [Unreleased]
4+
5+
### Fixed
6+
7+
- Fixed ISO week dates not being parsed properly in `fom_format()`.
8+
9+
310
## [2.0.4] - 2018-10-30
411

512
### Fixed

pendulum/formatting/formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def _check_parsed(self, parsed, now): # type: (dict, pendulum.DateTime) -> dict
469469

470470
if parsed["day_of_year"] is not None:
471471
dt = pendulum.parse(
472-
"{}-{}".format(validated["year"], parsed["day_of_year"])
472+
"{}-{:>03d}".format(validated["year"], parsed["day_of_year"])
473473
)
474474

475475
validated["month"] = dt.month

tests/datetime/test_from_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def test_from_format_with_invalid_padded_day():
132132
"1975-12-25T14:15:16+03:00",
133133
None,
134134
),
135+
("190022215", "YYDDDDHHmm", "2019-01-02T22:15:00+00:00", None),
135136
],
136137
)
137138
def test_from_format(text, fmt, expected, now):

0 commit comments

Comments
 (0)