From a6b0276966a9452641e9aed0db09b16ceda6e62d Mon Sep 17 00:00:00 2001 From: cerdelen Date: Sat, 7 Mar 2026 13:45:06 +0100 Subject: [PATCH] date: extend tz abbreviation lookup --- src/uu/date/src/date.rs | 3 +++ tests/by-util/test_date.rs | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 0c4e469d7..3510c783e 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -756,6 +756,7 @@ fn make_format_string(settings: &Settings) -> &str { static FIXED_OFFSET_ABBREVIATIONS: &[(&str, i32)] = &[ ("UTC", 0), ("GMT", 0), + ("MEST", 7200), // UTC+2 Middle European Summer Time // US timezones (GNU compatible) ("PST", -28800), // UTC-8 ("PDT", -25200), // UTC-7 @@ -776,6 +777,8 @@ static FIXED_OFFSET_ABBREVIATIONS: &[(&str, i32)] = &[ // German timezones ("MEZ", 3600), // UTC+1 ("MESZ", 7200), // UTC+2 + // Asian timezones + ("KST", 32400), // UTC+9 Korean Standard Time ]; /* spell-checker: enable */ diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index be7a4cd4a..75c5f45b7 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // -// spell-checker: ignore: AEDT AEST EEST NZDT NZST Kolkata Iseconds févr février janv janvier mercredi samedi sommes juin décembre Januar Juni Dezember enero junio diciembre gennaio giugno dicembre junho dezembro lundi dimanche Montag Sonntag Samstag sábado febr +// spell-checker: ignore: AEDT AEST EEST NZDT NZST Kolkata Iseconds févr février janv janvier mercredi samedi sommes juin décembre Januar Juni Dezember enero junio diciembre gennaio giugno dicembre junho dezembro lundi dimanche Montag Sonntag Samstag sábado febr MEST KST use std::cmp::Ordering; @@ -1173,6 +1173,16 @@ fn test_date_tz_abbreviation_fixed_offset_outside_season() { .arg("+%F %T %Z") .succeeds() .stdout_is("2026-01-15 16:00:00 UTC\n"); + + // MEST (UTC+2) used in winter + new_ucmd!() + .env("TZ", "UTC") + .arg("-u") + .arg("-d") + .arg("2026-01-15 10:00 MEST") + .arg("+%F %T %Z") + .succeeds() + .stdout_is("2026-01-15 08:00:00 UTC\n"); } #[test] @@ -2813,3 +2823,16 @@ fn test_date_debug_current_time() { // No parsing happens for "now", so no debug output assert_eq!(stderr, ""); } + +#[test] +fn test_korean_time_zone() { + // KST (UTC+9 korean standard time) used in winter + new_ucmd!() + .env("TZ", "UTC") + .arg("-u") + .arg("-d") + .arg("2026-01-15 10:00 KST") + .arg("+%F %T %Z") + .succeeds() + .stdout_is("2026-01-15 01:00:00 UTC\n"); +}