avm2: Implement toUTCString
This commit is contained in:
parent
292a9bda4b
commit
10be7ef3bf
|
@ -942,6 +942,27 @@ pub fn to_string<'gc>(
|
|||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
/// Implements the `toUTCString` method.
|
||||
pub fn to_utc_string<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
if let Some(this) = this.and_then(|this| this.as_date_object()) {
|
||||
if let Some(date) = this.date_time() {
|
||||
return Ok(AvmString::new(
|
||||
activation.context.gc_context,
|
||||
date.format("%a %b %-d %T %-Y UTC").to_string(),
|
||||
)
|
||||
.into());
|
||||
} else {
|
||||
return Ok("Invalid Date".into());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
/// Implements the `toLocaleString` method.
|
||||
pub fn to_locale_string<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
|
@ -1117,6 +1138,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
|||
("getTimezoneOffset", timezone_offset),
|
||||
("valueOf", time),
|
||||
("toString", to_string),
|
||||
("toUTCString", to_utc_string),
|
||||
("toLocaleString", to_locale_string),
|
||||
("toTimeString", to_time_string),
|
||||
("toLocaleTimeString", to_locale_time_string),
|
||||
|
|
Loading…
Reference in New Issue