From a6ec41e33f05b4fceab85e42af117ba56ceef4e1 Mon Sep 17 00:00:00 2001 From: tofpie <75836434+tofpie@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:33:31 +0100 Subject: [PATCH] Fix unit tests that can be failed due to daylight saving time (#968) Co-authored-by: tofpie --- boa/src/builtins/date/tests.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/boa/src/builtins/date/tests.rs b/boa/src/builtins/date/tests.rs index 1d397c92b7..1071fc564d 100644 --- a/boa/src/builtins/date/tests.rs +++ b/boa/src/builtins/date/tests.rs @@ -1276,7 +1276,13 @@ fn date_proto_to_string() -> Result<(), Box> { assert_eq!( Some(Value::string( - Local::now() + Local + .from_local_datetime(&NaiveDateTime::new( + NaiveDate::from_ymd(2020, 6, 8), + NaiveTime::from_hms_milli(9, 16, 15, 779) + )) + .earliest() + .unwrap() .format("Wed Jul 08 2020 09:16:15 GMT%:z") .to_string() )), @@ -1298,7 +1304,15 @@ fn date_proto_to_time_string() -> Result<(), Box> { assert_eq!( Some(Value::string( - Local::now().format("09:16:15 GMT%:z").to_string() + Local + .from_local_datetime(&NaiveDateTime::new( + NaiveDate::from_ymd(2020, 6, 8), + NaiveTime::from_hms_milli(9, 16, 15, 779) + )) + .earliest() + .unwrap() + .format("09:16:15 GMT%:z") + .to_string() )), actual );