From 9db8b47896b8ef010edb4a62b823b2839d11f447 Mon Sep 17 00:00:00 2001 From: nekevss Date: Fri, 29 Sep 2023 21:48:09 -0400 Subject: [PATCH] Fix time zone parsing issue/test logic --- boa_parser/src/temporal/date_time.rs | 10 ++++++++-- boa_parser/src/temporal/tests.rs | 17 +++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/boa_parser/src/temporal/date_time.rs b/boa_parser/src/temporal/date_time.rs index b1d4485b036..aab08b4c234 100644 --- a/boa_parser/src/temporal/date_time.rs +++ b/boa_parser/src/temporal/date_time.rs @@ -69,10 +69,16 @@ pub(crate) fn parse_annotated_date_time( tz = annotated_tz.tz; } + let tz = if tz.name.is_some() || tz.offset.is_some() { + Some(tz) + } else { + None + }; + Ok(IsoParseRecord { date: date_time.date, time: date_time.time, - tz: Some(tz), + tz, calendar: annotation_set.calendar, }) } @@ -113,7 +119,7 @@ fn parse_date_time( } else { if utc_required { return Err(Error::general( - "DateTimeUtcOffset is required.", + "DateTimeUTCOffset is required.", Position::new(1, cursor.pos() + 1), )); } diff --git a/boa_parser/src/temporal/tests.rs b/boa_parser/src/temporal/tests.rs index 0660a5cb683..64df2754542 100644 --- a/boa_parser/src/temporal/tests.rs +++ b/boa_parser/src/temporal/tests.rs @@ -40,18 +40,8 @@ fn temporal_date_time_max() { let tz = &result.tz.unwrap(); - let offset_results = &tz.offset.unwrap(); - - assert_eq!(offset_results.sign, -1); - assert_eq!(offset_results.hour, 3); - assert_eq!(offset_results.minute, 0); - assert_eq!( - offset_results - .second - .mul_add(f64::from(1_000_000), 0.0) - .trunc() as i64, - 0.123_456_789_f64.mul_add(1_000_000_f64, 0.0).trunc() as i64 - ); + // OffsetSubMinute is Empty when TimeZoneIdentifier is present. + assert!(&tz.offset.is_none()); let tz_name = &tz.name.clone().unwrap(); @@ -87,6 +77,9 @@ fn temporal_annotated_date_time() { let omit_result = TemporalDateTimeString::parse(false, &mut IsoCursor::new(omitted)).unwrap(); + println!("omit result is:"); + println!("{omit_result:?\n\n}"); + assert!(&omit_result.tz.is_none()); assert_eq!(&omit_result.calendar, &Some("iso8601".to_string()));