mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
LibJS: Add the Temporal.now namespace object
This will be home to various functions: - Temporal.now.timeZone() - Temporal.now.instant() - Temporal.now.plainDateTime() - Temporal.now.plainDateTimeISO() - Temporal.now.zonedDateTime() - Temporal.now.zonedDateTimeISO() - Temporal.now.plainDate() - Temporal.now.plainDateISO() - Temporal.now.plainTimeISO()
This commit is contained in:
parent
8269921212
commit
7da1fcb2ef
Notes:
sideshowbarker
2024-07-18 10:16:00 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/7da1fcb2ef8 Pull-request: https://github.com/SerenityOS/serenity/pull/8514 Reviewed-by: https://github.com/awesomekling ✅
@ -121,6 +121,7 @@ set(SOURCES
|
||||
Runtime/SymbolConstructor.cpp
|
||||
Runtime/SymbolObject.cpp
|
||||
Runtime/SymbolPrototype.cpp
|
||||
Runtime/Temporal/Now.cpp
|
||||
Runtime/Temporal/Temporal.cpp
|
||||
Runtime/TypedArray.cpp
|
||||
Runtime/TypedArrayConstructor.cpp
|
||||
|
23
Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
Normal file
23
Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Temporal/Now.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
||||
// 2 The Temporal.now Object, https://tc39.es/proposal-temporal/#sec-temporal-now-object
|
||||
Now::Now(GlobalObject& global_object)
|
||||
: Object(*global_object.object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
void Now::initialize(GlobalObject& global_object)
|
||||
{
|
||||
Object::initialize(global_object);
|
||||
}
|
||||
|
||||
}
|
22
Userland/Libraries/LibJS/Runtime/Temporal/Now.h
Normal file
22
Userland/Libraries/LibJS/Runtime/Temporal/Now.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
||||
class Now final : public Object {
|
||||
JS_OBJECT(Now, Object);
|
||||
|
||||
public:
|
||||
explicit Now(GlobalObject&);
|
||||
virtual void initialize(GlobalObject&) override;
|
||||
virtual ~Now() override = default;
|
||||
};
|
||||
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Temporal/Now.h>
|
||||
#include <LibJS/Runtime/Temporal/Temporal.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
@ -18,6 +19,11 @@ Temporal::Temporal(GlobalObject& global_object)
|
||||
void Temporal::initialize(GlobalObject& global_object)
|
||||
{
|
||||
Object::initialize(global_object);
|
||||
|
||||
auto& vm = this->vm();
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
||||
define_direct_property(vm.names.now, heap().allocate<Now>(global_object, global_object), attr);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user