diff --git a/src/items/offset.rs b/src/items/offset.rs index 9dc42f1..71a320b 100644 --- a/src/items/offset.rs +++ b/src/items/offset.rs @@ -281,6 +281,7 @@ fn timezone_name_to_offset(input: &str) -> ModalResult { "w" => Ok("-10"), "v" => Ok("-9"), "utc" => Ok("+0"), + "ut" => Ok("+0"), "u" => Ok("-8"), "t" => Ok("-7"), "sst" => Ok("-11"), @@ -423,6 +424,7 @@ mod tests { fn timezone_name_without_offset() { for (input, expected) in [ ("utc", off(false, 0, 0)), // UTC + ("ut", off(false, 0, 0)), // Universal Time = UTC (issue #280) ("gmt", off(false, 0, 0)), // UTC ("z", off(false, 0, 0)), // UTC ("west", off(false, 1, 0)), // positive offset diff --git a/src/lib.rs b/src/lib.rs index b9ce5fa..6dfac00 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -694,6 +694,19 @@ mod tests { } } + /// GNU `date` accepts bare `ut` / `UT` as a synonym for UTC (issue #280). + /// `gmt` and `GMT` already worked; this test covers all four forms. + #[test] + fn test_bare_utc_timezone_abbreviations() { + // All four should parse without error and produce a result in UTC (+00:00). + for abbr in ["ut", "UT", "gmt", "GMT"] { + let result = parse_datetime(abbr) + .unwrap_or_else(|_| panic!("bare timezone '{abbr}' should be accepted")); + let offset_secs = result.expect_in_range().offset().seconds(); + assert_eq!(offset_secs, 0, "'{abbr}' should resolve to UTC (+0)"); + } + } + #[test] fn test_weekday_only() { let now = Zoned::now();