Skip to content

Commit 6decb51

Browse files
committed
Support multi-segmented timezones
1 parent 84a3d17 commit 6decb51

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/haystack/timezone/iana.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn timezone_short_name(date: &DateTimeType) -> String {
5151
tz_id[tz_id.find('/').map_or(0, |v| v + 1)..].to_string()
5252
}
5353

54-
static PREFIXES: [&str; 14] = [
54+
static PREFIXES: [&str; 18] = [
5555
"Africa",
5656
"America",
5757
"Asia",
@@ -66,6 +66,10 @@ static PREFIXES: [&str; 14] = [
6666
"Mexico",
6767
"Pacific",
6868
"US",
69+
"America/Argentina",
70+
"America/Indiana",
71+
"America/Kentucky",
72+
"America/North_Dakota",
6973
];
7074

7175
fn find_timezone(name: &str) -> Result<Tz, String> {

tests/zinc/test_datetime.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ fn test_zinc_datetime_utc_decode_millis() {
6161
}
6262

6363
#[test]
64-
fn test_zinc_datetime_utc_decode_tz() {
64+
fn test_zinc_datetime_utc_decode_tz_london() {
6565
assert!(from_str("2020-02-10T16:00:00.0Z London").is_ok());
6666
}
6767

68+
#[test]
69+
fn test_zinc_datetime_utc_decode_tz_la_rioja() {
70+
assert!(from_str("2020-02-10T16:00:00.0+02:00 La_Rioja").is_ok());
71+
}
72+
6873
#[test]
6974
fn test_zinc_datetime_utc_decode_bad() {
7075
assert!(from_str("1996-12-19T16:39:57K").is_err());

0 commit comments

Comments
 (0)