date: extend tz abbreviation lookup

This commit is contained in:
cerdelen
2026-03-07 13:45:06 +01:00
committed by Daniel Hofstetter
parent 59aa4d7bbc
commit a6b0276966
2 changed files with 27 additions and 1 deletions
+3
View File
@@ -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 */
+24 -1
View File
@@ -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");
}