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

Temporal Instant migration cont. and related changes #3601

Merged
merged 6 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 0 additions & 11 deletions core/engine/src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,6 @@ impl JsBigInt {
Self::new(x.inner.as_ref().clone().add(y.inner.as_ref()))
}

/// Utility function for performing `+` operation on more than two values.
#[inline]
#[cfg(feature = "temporal")]
pub(crate) fn add_n(values: &[Self]) -> Self {
let mut result = Self::zero();
for big_int in values {
result = Self::add(&result, big_int);
}
result
}

/// Performs the `-` operation.
#[inline]
#[must_use]
Expand Down
19 changes: 19 additions & 0 deletions core/engine/src/builtins/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ impl OptionType for JsString {
}
}

impl OptionType for f64 {
fn from_value(value: JsValue, context: &mut Context) -> JsResult<Self> {
let value = value.to_number(context)?;

if !value.is_finite() {
return Err(JsNativeError::range()
.with_message("roundingIncrement must be finite.")
.into());
}

Ok(value)
}
}

#[derive(Debug, Copy, Clone, Default)]
pub(crate) enum RoundingMode {
Ceil,
Expand Down Expand Up @@ -171,6 +185,7 @@ impl fmt::Display for RoundingMode {
}
}

// TODO: remove once confirmed.
#[cfg(feature = "temporal")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum UnsignedRoundingMode {
Expand All @@ -182,7 +197,9 @@ pub(crate) enum UnsignedRoundingMode {
}

impl RoundingMode {
// TODO: remove once confirmed.
#[cfg(feature = "temporal")]
#[allow(dead_code)]
pub(crate) const fn negate(self) -> Self {
use RoundingMode::{
Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc,
Expand All @@ -201,7 +218,9 @@ impl RoundingMode {
}
}

// TODO: remove once confirmed.
#[cfg(feature = "temporal")]
#[allow(dead_code)]
pub(crate) const fn get_unsigned_round_mode(self, is_negative: bool) -> UnsignedRoundingMode {
use RoundingMode::{
Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc,
Expand Down
Loading
Loading