Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human readable names of the time-zones. #6

Closed
musically-ut opened this issue Mar 11, 2017 · 2 comments
Closed

Human readable names of the time-zones. #6

musically-ut opened this issue Mar 11, 2017 · 2 comments

Comments

@musically-ut
Copy link
Contributor

Printing the TimeZone in debug mode (i.e. using {:?} formatter) shows a correct name of the zone but that does not seem like a kosher way of arriving at the names.

I couldn't find another way. Since the Tz is an enum, it cannot provide an attribute like .name (re: #1). Also, providing a .to_string() (i.e. implementing a Display trait), is tricky because a time-zone can have several names depending on the context, e.g. both Asia/Kolkata and IST can be seen as expected outputs of .to_string().

Perhaps the Debug implementation can be moved to a function get_name which returns a String and then implementation of Debug could be:

impl Debug for Tz {
    fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
        write!(f, "{}", get_name(self))
    }
}

What do you think?

@djzin
Copy link
Contributor

djzin commented Mar 22, 2017

Hm, yes this seems like something that could be provided
Also relevant are the 'offset' names like 'CET' that get printed with datetimes but aren't publicly accessible
Probably would give a &'static str rather than a String

@musically-ut
Copy link
Contributor Author

Sounds like a good idea.

However, don't the abbreviations change depending on DST, e.g. CDST and CDT?

musically-ut added a commit to musically-ut/chrono-tz that referenced this issue Mar 26, 2017
@djzin djzin closed this as completed in #7 Apr 6, 2017
djc pushed a commit that referenced this issue Apr 15, 2024
Handle negative offsets, "Alternative" parsing error and comment lines
djc pushed a commit that referenced this issue Apr 15, 2024
 Improve build time by turning off regex cargo features
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants