v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-relative-time-format.h
Go to the documentation of this file.
1// Copyright 2018 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_OBJECTS_JS_RELATIVE_TIME_FORMAT_H_
6#define V8_OBJECTS_JS_RELATIVE_TIME_FORMAT_H_
7
9#ifndef V8_INTL_SUPPORT
10#error Internationalization is expected to be enabled.
11#endif // V8_INTL_SUPPORT
12
13#include <set>
14#include <string>
15
16#include "src/base/bit-field.h"
18#include "src/heap/factory.h"
19#include "src/objects/managed.h"
20#include "src/objects/objects.h"
21#include "unicode/uversion.h"
22
23// Has to be the last include (doesn't have include guards):
25
26namespace U_ICU_NAMESPACE {
27class RelativeDateTimeFormatter;
28} // namespace U_ICU_NAMESPACE
29
30namespace v8 {
31namespace internal {
32
33#include "torque-generated/src/objects/js-relative-time-format-tq.inc"
34
36 : public TorqueGeneratedJSRelativeTimeFormat<JSRelativeTimeFormat,
37 JSObject> {
38 public:
39 // Creates relative time format object with properties derived from input
40 // locales and options.
42 Isolate* isolate, DirectHandle<Map> map, DirectHandle<Object> locales,
43 DirectHandle<Object> options);
44
46 Isolate* isolate, DirectHandle<JSRelativeTimeFormat> format_holder);
47
49
50 // ecma402/#sec-Intl.RelativeTimeFormat.prototype.format
52 Isolate* isolate, Handle<Object> value_obj, Handle<Object> unit_obj,
54
55 // ecma402/#sec-Intl.RelativeTimeFormat.prototype.formatToParts
57 Isolate* isolate, Handle<Object> value_obj, Handle<Object> unit_obj,
59
60 V8_EXPORT_PRIVATE static const std::set<std::string>& GetAvailableLocales();
61
62 // RelativeTimeFormat accessors.
64
65 // Numeric: identifying whether numerical descriptions are always used, or
66 // used only when no more specific version is available (e.g., "1 day ago" vs
67 // "yesterday").
68 //
69 // ecma402/#sec-properties-of-intl-relativetimeformat-instances
70 enum class Numeric {
71 ALWAYS, // numerical descriptions are always used ("1 day ago")
72 AUTO // numerical descriptions are used only when no more specific
73 // version is available ("yesterday")
74 };
76 inline Numeric numeric() const;
77
78 // Bit positions in |flags|.
79 DEFINE_TORQUE_GENERATED_JS_RELATIVE_TIME_FORMAT_FLAGS()
80
81 static_assert(NumericBit::is_valid(Numeric::AUTO));
82 static_assert(NumericBit::is_valid(Numeric::ALWAYS));
83
85
87};
88
89} // namespace internal
90} // namespace v8
91
92#include "src/objects/object-macros-undef.h"
93
94#endif // V8_OBJECTS_JS_RELATIVE_TIME_FORMAT_H_
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSArray > FormatToParts(Isolate *isolate, Handle< Object > value_obj, Handle< Object > unit_obj, DirectHandle< JSRelativeTimeFormat > format)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > Format(Isolate *isolate, Handle< Object > value_obj, Handle< Object > unit_obj, DirectHandle< JSRelativeTimeFormat > format)
static V8_WARN_UNUSED_RESULT DirectHandle< JSObject > ResolvedOptions(Isolate *isolate, DirectHandle< JSRelativeTimeFormat > format_holder)
static V8_EXPORT_PRIVATE const std::set< std::string > & GetAvailableLocales()
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSRelativeTimeFormat > New(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Object > locales, DirectHandle< Object > options)
void set_numeric(Numeric numeric)
Handle< String > NumericAsString(Isolate *isolate) const
#define DECL_ACCESSORS(name,...)
#define DECL_PRINTER(Name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671