Skip to content
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
6 changes: 3 additions & 3 deletions src/builtins/compiled/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ impl PlainDate {
plain_time: Option<PlainTime>
) -> TemporalResult<crate::ZonedDateTime> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;
self.to_zoned_date_time_with_provider(time_zone, plain_time, &*provider)

;
self.to_zoned_date_time_with_provider(time_zone, plain_time, &*TZ_PROVIDER)
}
}
17 changes: 4 additions & 13 deletions src/builtins/compiled/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
builtins::TZ_PROVIDER,
options::{RelativeTo, RoundingOptions, Unit},
primitive::FiniteF64,
Duration, TemporalError, TemporalResult,
Duration, TemporalResult,
};

use core::cmp::Ordering;
Expand All @@ -20,10 +20,7 @@ impl Duration {
options: RoundingOptions,
relative_to: Option<RelativeTo>,
) -> TemporalResult<Self> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;
self.round_with_provider(options, relative_to, &*provider)
self.round_with_provider(options, relative_to, &*TZ_PROVIDER)
}

/// Returns the ordering between two [`Duration`], takes an optional
Expand All @@ -35,16 +32,10 @@ impl Duration {
two: &Duration,
relative_to: Option<RelativeTo>,
) -> TemporalResult<Ordering> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;
self.compare_with_provider(two, relative_to, &*provider)
self.compare_with_provider(two, relative_to, &*TZ_PROVIDER)
}

pub fn total(&self, unit: Unit, relative_to: Option<RelativeTo>) -> TemporalResult<FiniteF64> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;
self.total_with_provider(unit, relative_to, &*provider)
self.total_with_provider(unit, relative_to, &*TZ_PROVIDER)
}
}
9 changes: 2 additions & 7 deletions src/builtins/compiled/instant.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{
builtins::TZ_PROVIDER, options::ToStringRoundingOptions, Instant, TemporalError,
TemporalResult, TimeZone,
builtins::TZ_PROVIDER, options::ToStringRoundingOptions, Instant, TemporalResult, TimeZone,
};
use alloc::string::String;

Expand All @@ -14,10 +13,6 @@ impl Instant {
timezone: Option<&TimeZone>,
options: ToStringRoundingOptions,
) -> TemporalResult<String> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;

self.to_ixdtf_string_with_provider(timezone, options, &*provider)
self.to_ixdtf_string_with_provider(timezone, options, &*TZ_PROVIDER)
}
}
8 changes: 2 additions & 6 deletions src/builtins/compiled/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ mod plain_date_time;
mod zoneddatetime;

mod options {
use crate::{builtins::TZ_PROVIDER, options::RelativeTo, TemporalError, TemporalResult};
use crate::{builtins::TZ_PROVIDER, options::RelativeTo, TemporalResult};

impl RelativeTo {
pub fn try_from_str(source: &str) -> TemporalResult<Self> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;

Self::try_from_str_with_provider(source, &*provider)
Self::try_from_str_with_provider(source, &*TZ_PROVIDER)
}
}
}
17 changes: 4 additions & 13 deletions src/builtins/compiled/now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,30 @@ use crate::builtins::{
core::{Now, PlainDate, PlainDateTime, PlainTime},
TZ_PROVIDER,
};
use crate::{TemporalError, TemporalResult, TimeZone};
use crate::{TemporalResult, TimeZone};

impl Now {
/// Returns the current system time as a [`PlainDateTime`] with an optional
/// [`TimeZone`].
///
/// Enable with the `compiled_data` and `sys` feature flags.
pub fn plain_date_time_iso(self, time_zone: Option<TimeZone>) -> TemporalResult<PlainDateTime> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;
self.plain_date_time_iso_with_provider(time_zone, &*provider)
self.plain_date_time_iso_with_provider(time_zone, &*TZ_PROVIDER)
}

/// Returns the current system time as a [`PlainDate`] with an optional
/// [`TimeZone`].
///
/// Enable with the `compiled_data` and `sys` feature flags.
pub fn plain_date_iso(self, time_zone: Option<TimeZone>) -> TemporalResult<PlainDate> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;
self.plain_date_iso_with_provider(time_zone, &*provider)
self.plain_date_iso_with_provider(time_zone, &*TZ_PROVIDER)
}

/// Returns the current system time as a [`PlainTime`] with an optional
/// [`TimeZone`].
///
/// Enable with the `compiled_data` and `sys` feature flags.
pub fn plain_time_iso(self, time_zone: Option<TimeZone>) -> TemporalResult<PlainTime> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;
self.plain_time_with_provider(time_zone, &*provider)
self.plain_time_with_provider(time_zone, &*TZ_PROVIDER)
}
}
8 changes: 2 additions & 6 deletions src/builtins/compiled/plain_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
builtins::core::{PlainDateTime, ZonedDateTime},
builtins::TZ_PROVIDER,
options::Disambiguation,
TemporalError, TemporalResult, TimeZone,
TemporalResult, TimeZone,
};

impl PlainDateTime {
Expand All @@ -14,10 +14,6 @@ impl PlainDateTime {
time_zone: &TimeZone,
disambiguation: Disambiguation,
) -> TemporalResult<ZonedDateTime> {
let provider = TZ_PROVIDER
.lock()
.map_err(|_| TemporalError::general("Unable to acquire lock"))?;

self.to_zoned_date_time_with_provider(time_zone, disambiguation, &*provider)
self.to_zoned_date_time_with_provider(time_zone, disambiguation, &*TZ_PROVIDER)
}
}
Loading