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

setTimeout, setInterval and clearInterval (and the same clearTimeout) implementations #4130

Merged
merged 16 commits into from
Feb 3, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions core/engine/src/context/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,28 @@ pub struct JsDuration {
impl JsDuration {
/// Creates a new `JsDuration` from the given number of milliseconds.
#[must_use]
pub fn from_millis(millis: i64) -> Self {
pub fn from_millis(millis: u64) -> Self {
Self {
inner: std::time::Duration::from_millis(millis as u64),
inner: std::time::Duration::from_millis(millis),
}
}

/// Returns the number of milliseconds in this duration.
#[must_use]
pub fn as_millis(&self) -> i64 {
self.inner.as_millis() as i64
pub fn as_millis(&self) -> u64 {
self.inner.as_millis() as u64
}

/// Returns the number of seconds in this duration.
#[must_use]
pub fn as_secs(&self) -> i64 {
self.inner.as_secs() as i64
pub fn as_secs(&self) -> u64 {
self.inner.as_secs()
}

/// Returns the number of nanoseconds in this duration.
#[must_use]
pub fn as_nanos(&self) -> i64 {
self.inner.as_nanos() as i64
pub fn as_nanos(&self) -> u128 {
self.inner.as_nanos()
}
}

Expand Down