chrono
chrono copied to clipboard
Invalid local timezone in WASM
Hello,
I'm using chrono in WASM. My local timezone is UTC+2, but I get the same string twice when running this code:
let date : chrono::DateTime<Utc> = ...;
println!("{}", date);
println!("{}", date.with_timezone(&chrono::Local));
It seems that the local timezone is wrong when running in WASM. I tried both on Chrome and Firefox. I'm on Linux if it's relevant. I'm using chrono 0.4.19.
Did you activate the wasmbind feature?
That was indeed the issue. Should there be a compilation warning, or a panic when using the Local timezone without this feature? Rather than doing the wrong thing silently.
Just ran into this same issue, and I can confirm that the behaviour is rectified with the use of the wasmbind feature, with an essentially identical set up to OP.
It's slightly peculiar, because I'm sure it was showing the correct offset a few days/couple of weeks ago...
Anyway, I agree that some sort of warning would be better than silently producing the wrong behaviour. I'm not sure how this could be programatically detected, though.
The wasmbind feature is enabled by default since https://github.com/chronotope/chrono/pull/771.