mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +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
|
@ -300,6 +300,7 @@ namespace JS {
|
||||||
P(tanh) \
|
P(tanh) \
|
||||||
P(test) \
|
P(test) \
|
||||||
P(then) \
|
P(then) \
|
||||||
|
P(timeZone) \
|
||||||
P(toDateString) \
|
P(toDateString) \
|
||||||
P(toFixed) \
|
P(toFixed) \
|
||||||
P(toGMTString) \
|
P(toGMTString) \
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <LibJS/Runtime/GlobalObject.h>
|
#include <LibJS/Runtime/GlobalObject.h>
|
||||||
#include <LibJS/Runtime/Temporal/Now.h>
|
#include <LibJS/Runtime/Temporal/Now.h>
|
||||||
|
#include <LibJS/Runtime/Temporal/TimeZone.h>
|
||||||
|
|
||||||
namespace JS::Temporal {
|
namespace JS::Temporal {
|
||||||
|
|
||||||
|
@ -18,6 +19,28 @@ Now::Now(GlobalObject& global_object)
|
||||||
void Now::initialize(GlobalObject& global_object)
|
void Now::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@ public:
|
||||||
explicit Now(GlobalObject&);
|
explicit Now(GlobalObject&);
|
||||||
virtual void initialize(GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~Now() override = default;
|
virtual ~Now() override = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
JS_DECLARE_NATIVE_FUNCTION(time_zone);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Object* system_time_zone(GlobalObject&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue