mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 10:41:30 +00:00
LibJS Date: Added toUTCString()
toGMTString() is deprecated but is kept for compatibility's sake, but because HTTP Dates are always expressed in GMT, it should be safe to call toUTCString() in toGMTString().
This commit is contained in:
parent
036b5c2804
commit
d231c5e65b
Notes:
sideshowbarker
2024-07-18 21:08:21 +09:00
Author: https://github.com/leggenda47 🔰
Commit: d231c5e65b
Pull-request: https://github.com/SerenityOS/serenity/pull/5819
Reviewed-by: https://github.com/linusg ✅
3 changed files with 12 additions and 0 deletions
|
@ -235,6 +235,7 @@ namespace JS {
|
|||
P(toString) \
|
||||
P(toTimeString) \
|
||||
P(toUpperCase) \
|
||||
P(toUTCString) \
|
||||
P(trace) \
|
||||
P(trim) \
|
||||
P(trimEnd) \
|
||||
|
|
|
@ -81,6 +81,7 @@ void DatePrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.getUTCSeconds, get_utc_seconds, 0, attr);
|
||||
define_native_function(vm.names.toDateString, to_date_string, 0, attr);
|
||||
define_native_function(vm.names.toGMTString, to_gmt_string, 0, attr);
|
||||
define_native_function(vm.names.toUTCString, to_utc_string, 0, attr);
|
||||
define_native_function(vm.names.toISOString, to_iso_string, 0, attr);
|
||||
define_native_function(vm.names.toLocaleDateString, to_locale_date_string, 0, attr);
|
||||
define_native_function(vm.names.toLocaleString, to_locale_string, 0, attr);
|
||||
|
@ -399,10 +400,19 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_date_string)
|
|||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_gmt_string)
|
||||
{
|
||||
// toGMTString is deprecated but kept for compatibility.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toGMTString
|
||||
return to_utc_string(vm, global_object);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_utc_string)
|
||||
{
|
||||
auto* this_object = typed_this(vm, global_object);
|
||||
if (!this_object)
|
||||
return {};
|
||||
|
||||
// HTTP dates are always expressed in GMT.
|
||||
auto string = this_object->gmt_date_string();
|
||||
return js_string(vm, move(string));
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(get_utc_seconds);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_date_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_gmt_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_utc_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_iso_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_locale_date_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_locale_string);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue