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

Type for each timezone #30

Open
fenhl opened this issue Apr 3, 2019 · 4 comments
Open

Type for each timezone #30

fenhl opened this issue Apr 3, 2019 · 4 comments

Comments

@fenhl
Copy link

fenhl commented Apr 3, 2019

This feature was removed in #1. While I understand the reason for needing a single type that can dynamically represent different time zones, a project I'm currently working on needs to statically mark a value as being in a specific timezone:

#[derive(Deserialize)]
pub struct Event {
    pub start: DateTime<Europe::Berlin>,
    pub end: DateTime<Europe::Berlin>,
    // and some irrelevant fields ...
}

This is because the timestamps I'm deserializing are not marked with any timezone but the documentation specifies that they are to be interpreted as local times in Germany (and that no DST-ambiguous timestamps occur).

It would be great if this library could support both use-cases.

@quodlibetor
Copy link
Contributor

chrono-tz should support this.

@asnimansari
Copy link

+1

@lukesneeringer
Copy link

Yes, this would be extremely useful. The following simple use case is, as best as I can tell, impossible:

use chrono::DateTime;
use chrono_tz::US::Eastern;

struct Foo {
  create_time: DateTime<Eastern>,
}

As best as I can tell, it is only feasible to store DateTimes in Utc/FixedOffset/Local in a struct.

@robertbastian
Copy link

This would also provide dead-code elimination, so only data for time zones that are actually used would be included. Important for binary sizes on embedded.

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

5 participants