Temporal.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Runtime/GlobalObject.h>
  7. #include <LibJS/Runtime/Temporal/InstantConstructor.h>
  8. #include <LibJS/Runtime/Temporal/Now.h>
  9. #include <LibJS/Runtime/Temporal/Temporal.h>
  10. #include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
  11. namespace JS::Temporal {
  12. // 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects
  13. Temporal::Temporal(GlobalObject& global_object)
  14. : Object(*global_object.object_prototype())
  15. {
  16. }
  17. void Temporal::initialize(GlobalObject& global_object)
  18. {
  19. Object::initialize(global_object);
  20. auto& vm = this->vm();
  21. u8 attr = Attribute::Writable | Attribute::Configurable;
  22. define_direct_property(vm.names.now, heap().allocate<Now>(global_object, global_object), attr);
  23. define_direct_property(vm.names.Instant, global_object.temporal_instant_constructor(), attr);
  24. define_direct_property(vm.names.TimeZone, global_object.temporal_time_zone_constructor(), attr);
  25. }
  26. }