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

How to use this crate with runtime time-zones? #80

Closed
jorgecarleitao opened this issue Apr 23, 2021 · 1 comment
Closed

How to use this crate with runtime time-zones? #80

jorgecarleitao opened this issue Apr 23, 2021 · 1 comment

Comments

@jorgecarleitao
Copy link

jorgecarleitao commented Apr 23, 2021

Hi,

I have been investigating how to use this crate in the context of jorgecarleitao/arrow2#23, but have faced the challenge whereby our crate declares timezones as strings, while this one uses compile time timezones.

A simple exercise I am trying to achieve is to write the following function:

fn add_days(timestamps: Vec<i64>, timezone: &str, days: i64) -> Vec<i64>

where i64 is a timestamp represented in timezone. Do I need to match timezone to perform this calculation?

@jorgecarleitao
Copy link
Author

jorgecarleitao commented Apr 23, 2021

Ok, I found out; Something like

let timezone = chrono_tz::Tz::from_str(timezone)?;
timezone.timestamp(x, 0).timestamp()

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

1 participant