Skip to content

Commit

Permalink
Fix js_sys conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Oct 8, 2024
1 parent eab1c44 commit a6c3243
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion time/src/offset_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,8 @@ impl From<js_sys::Date> for OffsetDateTime {
/// This may panic if the timestamp can not be represented.
fn from(js_date: js_sys::Date) -> Self {
// get_time() returns milliseconds
let timestamp_nanos = (js_date.get_time() * Nanosecond::per(Millisecond) as f64) as i128;
let timestamp_nanos = js_date.get_time() as i128
* Nanosecond::per(Millisecond).cast_signed().extend::<i128>();
Self::from_unix_timestamp_nanos(timestamp_nanos)
.expect("invalid timestamp: Timestamp cannot fit in range")
}
Expand Down

0 comments on commit a6c3243

Please sign in to comment.