Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions rust/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ impl<'a> Parser<'a> {
}
Err(error) => return Err(error),
}
} else if self.end() {
// Year only (YYYY): month and day keep their default of 1
} else {
/*
Month and day in compact format (MMDD) or ordinal date (DDD)
Expand Down
1 change: 1 addition & 0 deletions tests/parsing/test_parse_iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@pytest.mark.parametrize(
["text", "expected"],
[
("2016", date(2016, 1, 1)),
("2016-10", date(2016, 10, 1)),
("2016-10-06", date(2016, 10, 6)),
# Ordinal date
Expand Down
8 changes: 8 additions & 0 deletions tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ def test_parse_interval() -> None:
assert interval.end.offset == 0


def test_parse_interval_of_years() -> None:
interval = pendulum.parse("2016/2017")

assert isinstance(interval, pendulum.Interval)
assert interval.start == pendulum.date(2016, 1, 1)
assert interval.end == pendulum.date(2017, 1, 1)


def test_parse_now() -> None:
assert pendulum.parse("now").timezone_name == "UTC"
assert (
Expand Down
Loading