mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibJS: Implement Temporal.now.timeZone()
This commit is contained in:
parent
265e89367e
commit
6cd16eceb3
3 changed files with 29 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Temporal/Now.h>
|
||||
#include <LibJS/Runtime/Temporal/TimeZone.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
||||
|
@ -18,6 +19,28 @@ Now::Now(GlobalObject& global_object)
|
|||
void Now::initialize(GlobalObject& global_object)
|
||||
{
|
||||
Object::initialize(global_object);
|
||||
|
||||
auto& vm = this->vm();
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
||||
define_native_function(vm.names.timeZone, time_zone, 0, attr);
|
||||
}
|
||||
|
||||
// 2.1.1 Temporal.now.timeZone ( ), https://tc39.es/proposal-temporal/#sec-temporal.now.timezone
|
||||
JS_DEFINE_NATIVE_FUNCTION(Now::time_zone)
|
||||
{
|
||||
// 1. Return ? SystemTimeZone().
|
||||
return system_time_zone(global_object);
|
||||
}
|
||||
|
||||
// 2.2.1 SystemTimeZone ( ), https://tc39.es/proposal-temporal/#sec-temporal-systemtimezone
|
||||
Object* system_time_zone(GlobalObject& global_object)
|
||||
{
|
||||
// 1. Let identifier be ! DefaultTimeZone().
|
||||
auto identifier = default_time_zone();
|
||||
|
||||
// 2. Return ? CreateTemporalTimeZone(identifier).
|
||||
return create_temporal_time_zone(global_object, identifier);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue