Instant.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Optional.h>
  8. #include <LibJS/Runtime/BigInt.h>
  9. #include <LibJS/Runtime/Object.h>
  10. namespace JS::Temporal {
  11. class Instant final : public Object {
  12. JS_OBJECT(Instant, Object);
  13. public:
  14. explicit Instant(BigInt& nanoseconds, Object& prototype);
  15. virtual ~Instant() override = default;
  16. BigInt const& nanoseconds() const { return m_nanoseconds; }
  17. private:
  18. virtual void visit_edges(Visitor&) override;
  19. // 8.4 Properties of Temporal.Instant Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-instant-instances
  20. // [[Nanoseconds]]
  21. BigInt& m_nanoseconds;
  22. };
  23. // -86400 * 10^17
  24. const auto INSTANT_NANOSECONDS_MIN = Crypto::SignedBigInteger::from_base(10, "-8640000000000000000000");
  25. // +86400 * 10^17
  26. const auto INSTANT_NANOSECONDS_MAX = Crypto::SignedBigInteger::from_base(10, "8640000000000000000000");
  27. bool is_valid_epoch_nanoseconds(BigInt const& epoch_nanoseconds);
  28. Object* create_temporal_instant(GlobalObject&, BigInt& nanoseconds, FunctionObject* new_target = nullptr);
  29. }