avm2: Strings passed to date constructor should be parsed

This commit is contained in:
EmperorBale 2023-01-01 19:48:58 -08:00 committed by Bale
parent ab3a1e6148
commit a51ffd0e9f
1 changed files with 5 additions and 1 deletions

View File

@ -274,7 +274,11 @@ pub fn instance_init<'gc>(
.map_year(|year| if year < 100.0 { year + 1900.0 } else { year })
.apply(date);
} else {
let timestamp = timestamp.coerce_to_number(activation)?;
let timestamp = if let Value::String(date_str) = timestamp {
parse_full_date(activation, *date_str).unwrap_or(f64::NAN)
} else {
timestamp.coerce_to_number(activation)?
};
if timestamp.is_finite() {
if let LocalResult::Single(time) =
Utc.timestamp_millis_opt(timestamp as i64)