-
Notifications
You must be signed in to change notification settings - Fork 57
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
Tz with a FixedOffset #11
Comments
Can you describe in more detail your use case? There are a bunch of fixed offset timezones defined in |
I did find a solution, but it wasn't obvious. I will pull out some code that shows the problem and how I managed to solve it. |
So the important thing to note is that tz is used after this if-else statement. As such, it needs to be a single type. The method to extract the fixed timezone wasn't obvious and took a lot of effort to work out. |
How do you detect the local timezone? I see chrono has a (sorry for the off topic) |
@meskio You can get a extern crate chrono; // 0.4.5
use chrono::prelude::*;
fn main() {
let created: DateTime<Local> = Local::now();
println!("{0} {0:?}", created.offset().fix())
} |
@quodlibetor Can I get |
+1 |
If someone can submit a PR I'll be happy to review it. |
I tried converting from a let fixed_offset = FixedOffset::east(0);
let temp_tz = chrono_tz::Tz::UTC;
let datetime_tz = temp_tz.from_utc_datetime(&Utc::now().naive_utc());
datetime_tz.with_timezone(&fixed_offset);
let new_tz = datetime_tz.timezone(); This compiles and runs fine, but there is some strange unexpected behaviour: trying to call
Should this be considered a bug? |
@lancelafontaine |
It is currently not possible to crate a
We could crate a Only what to do with the |
I am getting a fixed offset timezone with the type
chrono::FixedOffset
. I also have a timezone based onchrono_tz::Tz
. I am trying to unify these types to reduce code duplication.Is there a way to have a variable that is a FixedOffset or a Tz? I have tried a couple of things with no real success.
The text was updated successfully, but these errors were encountered: