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

Does tz-rs crate support custom format Datetime ? #30

Closed
baoyachi opened this issue Jul 13, 2022 · 2 comments
Closed

Does tz-rs crate support custom format Datetime ? #30

baoyachi opened this issue Jul 13, 2022 · 2 comments

Comments

@baoyachi
Copy link

baoyachi commented Jul 13, 2022

Now, I just find format DateTime to_string(). Does support custom format?

About code :

impl fmt::Display for DateTime {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let ut_offset = self.local_time_type().ut_offset();
        format_date_time(f, self.year, self.month, self.month_day, self.hour, self.minute, self.second, self.nanoseconds, ut_offset)
    }
}
@x-hgg-x
Copy link
Owner

x-hgg-x commented Jul 13, 2022

There isn't any custom formatter for DateTime at the moment, but all the fields has accessors so you can format it as you want.

@x-hgg-x
Copy link
Owner

x-hgg-x commented Jul 19, 2022

I have created the custom-format crate, which allow using custom format specifiers when formatting a value. You can use it to format a DateTime value as you wish.

@x-hgg-x x-hgg-x closed this as completed Jul 19, 2022
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