Skip to content

Commit

Permalink
Use already existing method to get all Timezones from chrono_tz.
Browse files Browse the repository at this point in the history
This means we can use the released version of chrono_tz.
  • Loading branch information
siedentop committed Jun 20, 2022
1 parent c87ad65 commit 831921f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Expand Up @@ -13,7 +13,8 @@ categories = ["command-line-utilities"]
[dependencies]
clap = { version = "~3.0.14", features = ["cargo", "derive"] }
chrono = "0.4.19"
chrono-tz = { git = "https://github.com/siedentop/chrono-tz", rev = "6bf301cf27efaa5e65d33d29c6de8180793a0bed" }
# chrono-tz = { git = "https://github.com/siedentop/chrono-tz", rev = "6bf301cf27efaa5e65d33d29c6de8180793a0bed" }
chrono-tz = "0.6.1"
lazy_static = "1.4.0"
regex = "1.5.4"
auto_correct_n_suggest = "1.0.0"
Expand Down
6 changes: 1 addition & 5 deletions src/timezones.rs
Expand Up @@ -12,18 +12,14 @@ pub fn parse_timezone(time_zone_str: &String) -> Result<Tz, RizzyError> {

pub fn guess_timezone(time_zone: String) -> Vec<String> {
let mut dictionary = Dictionary::new();
for tz in build_timezone_list() {
for tz in chrono_tz::TZ_VARIANTS.iter().map(|x| x.to_string()) {
dictionary.insert(tz);
}

let suggestions = dictionary.auto_suggest_alternative_words(time_zone);
suggestions.unwrap_or_default()
}

fn build_timezone_list() -> Vec<String> {
chrono_tz::TIMEZONES.keys().map(|x| x.to_string()).collect()
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 831921f

Please sign in to comment.