Skip to content

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

@jjpe

Description

@jjpe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions