Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/builtins/compiled/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ impl PlainDate {
/// Converts a `Date` to a `ZonedDateTime` in the UTC time zone.
pub fn to_zoned_date_time(
&self,
time_zone: TimeZone
time_zone: TimeZone,
plain_time: Option<PlainTime>
) -> TemporalResult<crate::ZonedDateTime> {
let provider = TZ_PROVIDER
Expand Down
25 changes: 24 additions & 1 deletion src/builtins/core/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ impl PlainDate {
// d. Let epochNs be ? GetEpochNanosecondsFor(timeZone, isoDateTime, compatible).
let epoch_ns = if let Some(time) = plain_time {
let result_iso = IsoDateTime::new(self.iso, time.iso);

tz.get_epoch_nanoseconds_for(
result_iso.unwrap_or_default(),
Disambiguation::Compatible,
Expand Down Expand Up @@ -724,9 +725,11 @@ impl FromStr for PlainDate {
}
}

#[cfg(test)]
#[cfg(all(test, feature = "tzdb"))]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the feature configuration shouldn't be here I think. You should be able to configure specific tests. With #[cfg(feature = "tzdb"] above the specific tests. I think references can be found in other test modules.

mod tests {
use tinystr::tinystr;
use crate::tzdb::FsTzdbProvider;


use super::*;

Expand Down Expand Up @@ -989,6 +992,26 @@ mod tests {
assert_eq!(with_day.day().unwrap(), 17);
}

// test toZonedDateTime
#[test]
fn to_zoned_date_time() {
let date = PlainDate::from_str("2020-01-01").unwrap();
let tz = TimeZone::try_from_str("UTC").unwrap();
let provider = &FsTzdbProvider::default();
let zdt = date
.to_zoned_date_time_with_provider(tz, None, provider)
.unwrap();
assert_eq!(zdt.year_with_provider(provider).unwrap(), 2020);
assert_eq!(zdt.month_with_provider(provider).unwrap(), 1);
assert_eq!(zdt.day_with_provider(provider).unwrap(), 1);
assert_eq!(zdt.hour_with_provider(provider).unwrap(), 0);
assert_eq!(zdt.minute_with_provider(provider).unwrap(), 0);
assert_eq!(zdt.second_with_provider(provider).unwrap(), 0);
assert_eq!(zdt.millisecond_with_provider(provider).unwrap(), 0);
assert_eq!(zdt.microsecond_with_provider(provider).unwrap(), 0);
assert_eq!(zdt.nanosecond_with_provider(provider).unwrap(), 0);
}

// test262/test/built-ins/Temporal/Calendar/prototype/month/argument-string-invalid.js
#[test]
fn invalid_strings() {
Expand Down
Loading