Skip to content

Commit

Permalink
support timezone abbreviation
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Sep 30, 2024
1 parent a0a20ab commit 77c9c66
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "test-with"
version = "0.14.1"
version = "0.14.2"
authors = ["Antonio Yang <[email protected]>"]
edition = "2021"
license = "MIT"
Expand Down
51 changes: 26 additions & 25 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2928,33 +2928,34 @@ fn check_timezone(attr_str: &String) -> (bool, Vec<&str>) {

for tz in attr_str.split(',') {
let parsed_tz = match tz {
"NZDT" => Ok(13),
"NZST" => Ok(12),
"AEDT" => Ok(11),
// "ACDT" => Ok(10.5)
"AEST" => Ok(10),
// "ACST" => Ok(9.5)
"KST" | "JST" => Ok(9),
"HKT" | "WITA" | "AWST" => Ok(8), // Duplicate PST
"NZDT" => Ok(13 * 60),
"NZST" => Ok(12 * 60),
"AEDT" => Ok(11 * 60),
"ACDT" => Ok(10 * 60 + 30),
"AEST" => Ok(10 * 60),
"ACST" => Ok(9 * 60 + 30),
"KST" | "JST" => Ok(9 * 60),
"HKT" | "WITA" | "AWST" => Ok(8 * 60),
"PST" => abort_call_site!("PST can be GMT+8 or GMT-8, please use +8 or -8 instead"),
"WIB" => Ok(7),
// "CST" => Ok(8), // Duplicate CST
// "IST" => Ok(5.5)
"PKT" => Ok(5),
"EAT" | "EEST" | "IDT" | "MSK" => Ok(3),
"CAT" | "EET" | "CEST" | "SAST" => Ok(2), // Duplicate IST
"CET" | "WAT" | "WEST" | "BST" => Ok(1),
"CST" => abort_call_site!("PST can be GMT+8 or GMT-6, please use +8 or -6 instead"),
"IST" => Ok(5 * 60 + 30),
"PKT" => Ok(5 * 60),
"EAT" | "EEST" | "IDT" | "MSK" => Ok(3 * 60),
"CAT" | "EET" | "CEST" | "SAST" => Ok(2 * 60),
"CET" | "WAT" | "WEST" | "BST" => Ok(1 * 60),
"UTC" | "GMT" | "WET" => Ok(0),
// "NDT" => Ok(-2.5)
// "NST" => Ok(-3.5)
"ADT" => Ok(-3),
"AST" | "EDT" => Ok(-4),
"EST" | "CDT" => Ok(-5),
"MDT" => Ok(-6), // Another CST here
"MST" | "PDT" => Ok(-7),
"AKDT" => Ok(-8), // Another PST here
"HDT" | "AKST" => Ok(-9),
"HST" => Ok(-10),
_ => tz.parse::<i32>(),
"NDT" => Ok(-2 * 60 - 30),
"NST" => Ok(-3 * 60 - 30),
"ADT" => Ok(-3 * 60),
"AST" | "EDT" => Ok(-4 * 60),
"EST" | "CDT" => Ok(-5 * 60),
"MDT" => Ok(-6 * 60),
"MST" | "PDT" => Ok(-7 * 60),
"AKDT" => Ok(-8 * 60),
"HDT" | "AKST" => Ok(-9 * 60),
"HST" => Ok(-10 * 60),
_ => tz.parse::<i32>().map(|tz| tz * 60),
};
if let Ok(parsed_tz) = parsed_tz {
match_tz |= current_tz == parsed_tz;
Expand Down

0 comments on commit 77c9c66

Please sign in to comment.