Skip to content

Commit 3382956

Browse files
Fix incorrect date offset calculation in rust (#918)
Co-authored-by: Holly <[email protected]>
1 parent 0e92991 commit 3382956

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

rust/src/parsing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ impl<'a> Parser<'a> {
891891
}
892892

893893
for i in 1..14 {
894-
if ord < MONTHS_OFFSETS[leap][i] {
894+
if ord <= MONTHS_OFFSETS[leap][i] {
895895
let day = ord as u32 - MONTHS_OFFSETS[leap][i - 1] as u32;
896896
let month = (i - 1) as u32;
897897

tests/parsing/test_parsing.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,19 @@ def test_iso8601_week_number():
381381
assert parsed.microsecond == 0
382382
assert parsed.tzinfo is None
383383

384+
# Test case for bug #916 - 2026W36 should parse correctly
385+
text = "2026W36"
386+
parsed = parse(text)
387+
388+
assert parsed.year == 2026
389+
assert parsed.month == 8
390+
assert parsed.day == 31
391+
assert parsed.hour == 0
392+
assert parsed.minute == 0
393+
assert parsed.second == 0
394+
assert parsed.microsecond == 0
395+
assert parsed.tzinfo is None
396+
384397

385398
def test_iso8601_week_number_with_time():
386399
text = "2012-W05T09"

0 commit comments

Comments
 (0)