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

Utc::now() panicks when targetting WebAssembly #284

Closed
jjpe opened this issue Nov 1, 2018 · 5 comments
Closed

Utc::now() panicks when targetting WebAssembly #284

jjpe opened this issue Nov 1, 2018 · 5 comments

Comments

@jjpe
Copy link
Contributor

jjpe commented Nov 1, 2018

I have a crate that uses chrono extensively, and I am trying to enable that crate to target WASM.

However, I've traced a panic! I'm getting to the UTC::now() constructor fn. Specifically:

#[cfg(feature="clock")]
impl Utc {
    // ...
    pub fn now() -> DateTime<Utc> {
        let spec = oldtime::get_time(); // <-- offending line
        let naive = NaiveDateTime::from_timestamp(spec.sec, spec.nsec as u32);
        DateTime::from_utc(naive, Utc)
    }
}

I'm hoping a fix for this can be as easy as an extra version of UTC::now() for WASM, but I'm unsure.

@jjpe
Copy link
Contributor Author

jjpe commented Nov 4, 2018

I've added initial support for wasm32 @ PR #287.

@David-OConnor
Copy link

Note that this is still unmerged.

@jasonwilliams
Copy link

jasonwilliams commented Jun 5, 2019

@quodlibetor @GuillaumeGomez are you able to help with this? Some projects targeting web assembly break because of this issue, looks like there's been a PR

@ctaggart
Copy link

ctaggart commented Aug 20, 2019

I just ran into this. It looks like #331 has the minimal changes. Thank you @evq for picking this back up!

@pitdicker
Copy link
Collaborator

Fixed in #331.

@djc djc closed this as completed Jun 7, 2023
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

6 participants