Skip to content
Merged
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
17 changes: 16 additions & 1 deletion src/items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,18 @@ pub fn parse(input: &mut &str) -> ModalResult<Vec<Item>> {
if time_seen {
return Err(expect_error(input, "time cannot appear more than once"));
}
time_seen = true;

if t.offset.is_some() {
if tz_seen {
return Err(expect_error(
input,
"timezone cannot appear more than once",
));
}
tz_seen = true;
}

time_seen = true;
}
Item::Year(_) => {
if year_seen {
Expand Down Expand Up @@ -591,6 +599,13 @@ mod tests {
.to_string()
.contains("timezone cannot appear more than once"));

let result = parse(&mut "m1y");
assert!(result.is_err());
assert!(result
.unwrap_err()
.to_string()
.contains("timezone cannot appear more than once"));

let result = parse(&mut "2025-05-19 abcdef");
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("unexpected input"));
Expand Down