shunsock / timezone_translator

simple command-line utility that converts a given time from one timezone to another.
MIT License
23 stars 1 forks source link

Add default timezone feature to timezone_translator #28

Closed shunsock closed 3 months ago

shunsock commented 3 months ago

About

This pull request introduces a new feature that allows users to set a default timezone for the timezone_translator utility. The main changes include:

  1. Adding a default value for the to/from parameter.
  2. Updating the documentation to reflect the new feature.

Feel free to merge as this is NOT a breaking change.

Issue

Comment on Reddit: https://www.reddit.com/r/rust/comments/1dr9x58/comment/laudhjq/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button Issue on Repo: https://github.com/shunsock/timezone_translator/issues/27

Test

We have added tests to ensure the default timezone is applied correctly. The tests use regex to check the output, as the output may vary across different machines.

#[cfg(test)]
mod tests {
    use super::*;
    use regex::Regex;

    #[test]
    fn test_check_output_match_timezone() {
        let local_timezone_str = provide_local_timezone_string();
        let re: Regex = Regex::new(r"^[a-zA-Z_/]+$").unwrap();
        assert!(re.is_match(&local_timezone_str));
    }
}