@vertigis/arcgis-extensions 47.1.0 → 47.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AccessDeniedError.js +1 -1
- package/AppConfig.schema.json +6 -2
- package/NotFoundError.js +1 -1
- package/data/ArcGISServiceTableExtension.js +1 -1
- package/data/Feature.d.ts +7 -7
- package/data/Feature.js +1 -1
- package/data/FeatureList.js +1 -1
- package/data/FeatureSaveError.js +1 -1
- package/data/FieldExtension.js +1 -1
- package/data/Schema.js +1 -1
- package/data/convert.d.ts +6 -2
- package/data/convert.js +1 -1
- package/docs/html/assets/navigation.js +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/data_Feature.Feature.html +6 -6
- package/docs/html/classes/support_FormatSettings.FormatSettings.html +10 -5
- package/docs/html/classes/support_Serializable.SerializableBase.html +1 -1
- package/docs/html/classes/utilities_Time.Time.html +11 -0
- package/docs/html/classes/{utilities_date.DateFormatter.html → utilities_format_date.DateFormatter.html} +57 -56
- package/docs/html/classes/{utilities_number.NumberFormatter.html → utilities_format_number.NumberFormatter.html} +54 -54
- package/docs/html/classes/utilities_format_string.StringFormatter.html +49 -0
- package/docs/html/classes/utilities_format_time.TimeFormatter.html +137 -0
- package/docs/html/enums/{utilities_date.DateFormat.html → utilities_format_formats.DateFormat.html} +12 -11
- package/docs/html/enums/{utilities_number.NumberFormat.html → utilities_format_formats.NumberFormat.html} +9 -8
- package/docs/html/enums/utilities_format_formats.TimeFormat.html +16 -0
- package/docs/html/functions/utilities_field.isNumericFieldType.html +1 -0
- package/docs/html/functions/{utilities_date.ERR_TIME_ZONE_INVALID.html → utilities_format_date.ERR_TIME_ZONE_INVALID.html} +1 -1
- package/docs/html/functions/{utilities_date.esriFormatToGeocortexFormat.html → utilities_format_date.esriFormatToGeocortexFormat.html} +2 -2
- package/docs/html/functions/{utilities_date.format.html → utilities_format_date.format.html} +3 -3
- package/docs/html/functions/{utilities_date.isValid.html → utilities_format_date.isValid.html} +1 -1
- package/docs/html/functions/{utilities_date.isValidTimeZone.html → utilities_format_date.isValidTimeZone.html} +1 -1
- package/docs/html/functions/{utilities_date.parse.html → utilities_format_date.parse.html} +3 -3
- package/docs/html/functions/{utilities_date.parseUtc.html → utilities_format_date.parseUtc.html} +3 -3
- package/docs/html/functions/{utilities_number.format.html → utilities_format_number.format.html} +3 -3
- package/docs/html/functions/{utilities_number.parse.html → utilities_format_number.parse.html} +3 -3
- package/docs/html/functions/{utilities_string.format.html → utilities_format_string.format.html} +3 -3
- package/docs/html/functions/utilities_format_time.esriFormatToGeocortexFormat.html +5 -0
- package/docs/html/functions/utilities_format_time.format.html +9 -0
- package/docs/html/functions/utilities_format_time.parse.html +15 -0
- package/docs/html/hierarchy.html +1 -1
- package/docs/html/interfaces/data_Feature.FormatOptions.html +21 -13
- package/docs/html/interfaces/data_convert.FromCsvOptions.html +6 -3
- package/docs/html/interfaces/data_convert.FromShapefileOptions.html +6 -3
- package/docs/html/interfaces/data_convert.FromXLSXOptions.html +6 -3
- package/docs/html/interfaces/data_convert.ToCsvOptions.html +6 -3
- package/docs/html/interfaces/data_convert.ToShapefileOptions.html +6 -3
- package/docs/html/interfaces/data_convert.ToXLSXOptions.html +6 -3
- package/docs/html/interfaces/data_convert.UploadDataOptions.html +6 -3
- package/docs/html/interfaces/json_FeatureLayerJson.FeatureLayerJson.html +2 -2
- package/docs/html/interfaces/json_StreamLayerJson.StreamLayerJson.html +2 -2
- package/docs/html/interfaces/mapping_FeatureLayerExtension.FeatureLayerProperties.html +2 -2
- package/docs/html/interfaces/mapping_FeatureLayerExtensionBase.FeatureLayerBaseProperties.html +2 -2
- package/docs/html/interfaces/support_FormatSettings.FormatSettingsProperties.html +10 -6
- package/docs/html/interfaces/utilities_format_FormatSettings.FormatSettings.html +21 -0
- package/docs/html/interfaces/{utilities_date.DateFormatterProperties.html → utilities_format_date.DateFormatterProperties.html} +12 -11
- package/docs/html/interfaces/{utilities_date.DateSettings.html → utilities_format_date.DateSettings.html} +6 -5
- package/docs/html/interfaces/utilities_format_date.FormatOptions.html +12 -0
- package/docs/html/interfaces/utilities_format_date.ParseOptions.html +14 -0
- package/docs/html/interfaces/{utilities_number.FormatOptions.html → utilities_format_number.FormatOptions.html} +9 -8
- package/docs/html/interfaces/{utilities_number.NumberFormatterProperties.html → utilities_format_number.NumberFormatterProperties.html} +13 -13
- package/docs/html/interfaces/{utilities_number.NumberSettings.html → utilities_format_number.NumberSettings.html} +7 -7
- package/docs/html/interfaces/{utilities_number.ParseOptions.html → utilities_format_number.ParseOptions.html} +4 -4
- package/docs/html/interfaces/utilities_format_string.FormatOptions.html +30 -0
- package/docs/html/interfaces/utilities_format_time.FormatOptions.html +7 -0
- package/docs/html/interfaces/utilities_format_time.ParseOptions.html +9 -0
- package/docs/html/interfaces/utilities_format_time.TimeFormatterProperties.html +14 -0
- package/docs/html/interfaces/utilities_format_time.TimeSettings.html +10 -0
- package/docs/html/interfaces/utilities_log.LogOptions.html +16 -12
- package/docs/html/modules/utilities_FormatSettings.html +3 -3
- package/docs/html/modules/utilities_Time.html +2 -0
- package/docs/html/modules/utilities_date.html +18 -18
- package/docs/html/modules/utilities_format_FormatSettings.html +3 -0
- package/docs/html/modules/utilities_format__utils.html +1 -0
- package/docs/html/modules/utilities_format_date.html +16 -0
- package/docs/html/modules/utilities_format_formats.html +4 -0
- package/docs/html/modules/utilities_format_number.html +9 -0
- package/docs/html/modules/utilities_format_string.html +5 -0
- package/docs/html/modules/utilities_format_time.html +11 -0
- package/docs/html/modules/utilities_number.html +11 -11
- package/docs/html/modules/utilities_string.html +5 -5
- package/docs/html/types/json_FieldJson.FieldJsonType.html +1 -1
- package/docs/html/types/json_PopupInfoJson.DateFormatJsonType.html +1 -1
- package/docs/html/variables/utilities_format_FormatSettings.settings.html +3 -0
- package/docs/html/variables/{utilities_date.DEFAULT_PARSING_FORMATS.html → utilities_format_date.DEFAULT_PARSING_FORMATS.html} +1 -1
- package/docs/html/variables/{utilities_date.INVALID_DATE.html → utilities_format_date.INVALID_DATE.html} +1 -1
- package/docs/html/variables/{utilities_date.settings.html → utilities_format_date.settings.html} +1 -1
- package/docs/html/variables/{utilities_FormatSettings.settings.html → utilities_format_number.settings.html} +1 -2
- package/docs/html/variables/utilities_format_time.DEFAULT_PARSING_FORMATS.html +2 -0
- package/docs/html/variables/{utilities_number.settings.html → utilities_format_time.settings.html} +1 -1
- package/docs/html/variables/version.version.html +1 -1
- package/json/FieldJson.d.ts +1 -1
- package/json/PopupInfoJson.d.ts +1 -1
- package/locale/language.d.ts +1 -1
- package/locale/language.js +1 -1
- package/mapping/ArcGISSublayerExtension.js +1 -1
- package/mapping/FeatureLayerExtensionBase.js +1 -1
- package/mapping/MapExtension.js +1 -1
- package/mapping/SubtypeGroupLayerExtension.js +1 -1
- package/mapping/SubtypeSublayerExtension.js +1 -1
- package/mapping/_SublayerExtension.js +1 -1
- package/mapping/support/featureService.js +1 -1
- package/package.json +3 -2
- package/portal/Field.d.ts +1 -1
- package/portal/Field.js +1 -1
- package/portal/Format.d.ts +2 -2
- package/support/FormatSettings.d.ts +21 -7
- package/support/FormatSettings.js +1 -1
- package/support/InitializeError.js +1 -1
- package/tasks/identify/IdentifyError.js +1 -1
- package/tasks/query/QueryError.js +1 -1
- package/tasks/search/SearchError.js +1 -1
- package/tasks/search/_utilities.js +1 -1
- package/tasks/search/support/_querySearchProviderUtils.js +1 -1
- package/utilities/FormatSettings.d.ts +6 -31
- package/utilities/FormatSettings.js +1 -1
- package/utilities/GeometryServiceError.js +1 -1
- package/utilities/Time.d.ts +22 -0
- package/utilities/Time.js +1 -0
- package/utilities/date.d.ts +35 -349
- package/utilities/date.js +1 -1
- package/utilities/field.d.ts +2 -0
- package/utilities/field.js +1 -1
- package/utilities/format/FormatSettings.d.ts +41 -0
- package/utilities/format/FormatSettings.js +1 -0
- package/utilities/format/_utils.d.ts +1 -0
- package/utilities/format/_utils.js +1 -0
- package/utilities/format/date.d.ts +336 -0
- package/utilities/format/date.js +1 -0
- package/utilities/format/formats.d.ts +127 -0
- package/utilities/format/formats.js +1 -0
- package/utilities/format/number.d.ts +193 -0
- package/utilities/format/number.js +1 -0
- package/utilities/format/string.d.ts +96 -0
- package/utilities/format/string.js +1 -0
- package/utilities/format/time.d.ts +206 -0
- package/utilities/format/time.js +1 -0
- package/utilities/log.d.ts +2 -2
- package/utilities/number.d.ts +25 -218
- package/utilities/number.js +1 -1
- package/utilities/string.d.ts +16 -81
- package/utilities/string.js +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/docs/html/classes/utilities_string.StringFormatter.html +0 -42
- package/docs/html/interfaces/utilities_FormatSettings.FormatSettings.html +0 -17
- package/docs/html/interfaces/utilities_date.FormatOptions.html +0 -9
- package/docs/html/interfaces/utilities_date.ParseOptions.html +0 -11
- package/docs/html/interfaces/utilities_string.FormatOptions.html +0 -22
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import type { PropertyDefs } from "../../support/Serializable.js";
|
|
2
|
+
import { SerializableBase } from "../../support/Serializable.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates an error message for an invalid time zone.
|
|
5
|
+
*
|
|
6
|
+
* @param timeZone The invalid time zone string.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ERR_TIME_ZONE_INVALID: (timeZone: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* The default set of formats used for parsing date values.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_PARSING_FORMATS: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Default settings that affect how dates are formatted and parsed.
|
|
15
|
+
*/
|
|
16
|
+
export interface DateSettings {
|
|
17
|
+
/**
|
|
18
|
+
* The default format for formatting dates. See
|
|
19
|
+
* {@link utilities/format/date!DateFormatter.format}.
|
|
20
|
+
*/
|
|
21
|
+
defaultFormat?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Either a single format, or one of several possible formats that the input
|
|
24
|
+
* is expected to be in. If specified, the input must _exactly_ match. The
|
|
25
|
+
* syntax is the same as for
|
|
26
|
+
* {@link utilities/format/date!DateFormatter.format}.
|
|
27
|
+
*/
|
|
28
|
+
defaultParseFormat?: string | string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Options supported by {@link format}.
|
|
32
|
+
*/
|
|
33
|
+
export interface FormatOptions {
|
|
34
|
+
/**
|
|
35
|
+
* The locale to use when formatting the date. If not specified, the current
|
|
36
|
+
* locale is used (see locale module).
|
|
37
|
+
*/
|
|
38
|
+
locale?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The date format. See {@link utilities/format/date!DateFormatter.format}.
|
|
41
|
+
*/
|
|
42
|
+
format?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The time zone of the date being formatted.
|
|
45
|
+
*/
|
|
46
|
+
timeZone?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Indicates if the date should be formatted without the time component even
|
|
49
|
+
* if the format suggests to include a time.
|
|
50
|
+
*/
|
|
51
|
+
isDateOnly?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options supported by {@link parse}.
|
|
55
|
+
*/
|
|
56
|
+
export interface ParseOptions {
|
|
57
|
+
/**
|
|
58
|
+
* The locale to use when parsing the date. If not specified, the current
|
|
59
|
+
* locale is used (see locale module).
|
|
60
|
+
*/
|
|
61
|
+
locale?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Either a single format, or one of several possible formats that the input
|
|
64
|
+
* is expected to be in. If specified, the input must _exactly_ match. See
|
|
65
|
+
* {@link utilities/format/date!DateFormatter.format}.
|
|
66
|
+
*/
|
|
67
|
+
format?: string | string[];
|
|
68
|
+
/**
|
|
69
|
+
* The time zone of the date being parsed.
|
|
70
|
+
*/
|
|
71
|
+
timeZone?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Indicates if the date should be parsed without expecting the time
|
|
74
|
+
* component even if the format suggests there is a time.
|
|
75
|
+
*/
|
|
76
|
+
isDateOnly?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A special date instance that signifies failure to parse a date. This way of
|
|
80
|
+
* signifying failure is in keeping with "new Date(string)" and
|
|
81
|
+
* "Date.parse(string)".
|
|
82
|
+
*/
|
|
83
|
+
export declare const INVALID_DATE: Date;
|
|
84
|
+
/**
|
|
85
|
+
* Determines whether the given date object represents a valid date.
|
|
86
|
+
*
|
|
87
|
+
* @param date The date to check.
|
|
88
|
+
*/
|
|
89
|
+
export declare function isValid(date: Date): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Formats a date for display in the current locale.
|
|
92
|
+
*
|
|
93
|
+
* @param date The date to format.
|
|
94
|
+
*/
|
|
95
|
+
export declare function format(date: Date): string;
|
|
96
|
+
/**
|
|
97
|
+
* Formats a date for display.
|
|
98
|
+
*
|
|
99
|
+
* @param format See {@link utilities/format/date!DateFormatter.format}.
|
|
100
|
+
* @param date The date to format.
|
|
101
|
+
*/
|
|
102
|
+
export declare function format(format: string, date: Date): string;
|
|
103
|
+
/**
|
|
104
|
+
* Formats a date for display.
|
|
105
|
+
*
|
|
106
|
+
* @param options Specifies the format settings to use.
|
|
107
|
+
* @param date The date to format.
|
|
108
|
+
*/
|
|
109
|
+
export declare function format(options: FormatOptions, date: Date): string;
|
|
110
|
+
/**
|
|
111
|
+
* Parses a value into a Date object. The input is assumed to be in local time.
|
|
112
|
+
*
|
|
113
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
114
|
+
* (always UTC).
|
|
115
|
+
* @returns A Date object corresponding to the input, which might be an Invalid
|
|
116
|
+
* Date (i.e. getTime() will be NaN).
|
|
117
|
+
*/
|
|
118
|
+
export declare function parse(input: unknown): Date;
|
|
119
|
+
/**
|
|
120
|
+
* Parses a value into a Date object. The input is assumed to be in local time.
|
|
121
|
+
*
|
|
122
|
+
* @param format See {@link ParseOptions.format}.
|
|
123
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
124
|
+
* (always UTC).
|
|
125
|
+
* @returns A Date object corresponding to the input, which might be an Invalid
|
|
126
|
+
* Date (i.e. getTime() will be NaN).
|
|
127
|
+
*/
|
|
128
|
+
export declare function parse(format: string | string[], input: unknown): Date;
|
|
129
|
+
/**
|
|
130
|
+
* Parses a value into a Date object. The input is assumed to be in local time.
|
|
131
|
+
*
|
|
132
|
+
* @param options The options to use for parsing.
|
|
133
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
134
|
+
* (always UTC).
|
|
135
|
+
* @returns A Date object corresponding to the input, which might be an Invalid
|
|
136
|
+
* Date (i.e. getTime() will be NaN).
|
|
137
|
+
*/
|
|
138
|
+
export declare function parse(options: ParseOptions, input: unknown): Date;
|
|
139
|
+
/**
|
|
140
|
+
* Parses a value into a Date object. The input is assumed to be in UTC.
|
|
141
|
+
*
|
|
142
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps.
|
|
143
|
+
* @returns A Date object corresponding to the input, which might be an Invalid
|
|
144
|
+
* Date (i.e. getTime() will be NaN).
|
|
145
|
+
*/
|
|
146
|
+
export declare function parseUtc(input: unknown): Date;
|
|
147
|
+
/**
|
|
148
|
+
* Parses a value into a Date object. The input is assumed to be in UTC.
|
|
149
|
+
*
|
|
150
|
+
* @param format See {@link ParseOptions.format}.
|
|
151
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps.
|
|
152
|
+
* @returns A Date object corresponding to the input, which might be an Invalid
|
|
153
|
+
* Date (i.e. getTime() will be NaN).
|
|
154
|
+
*/
|
|
155
|
+
export declare function parseUtc(format: string | string[], input: unknown): Date;
|
|
156
|
+
/**
|
|
157
|
+
* Parses a value into a Date object. The input is assumed to be in UTC.
|
|
158
|
+
*
|
|
159
|
+
* @param options The options to use for parsing.
|
|
160
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps.
|
|
161
|
+
* @returns A Date object corresponding to the input, which might be an Invalid
|
|
162
|
+
* Date (i.e. getTime() will be NaN).
|
|
163
|
+
*/
|
|
164
|
+
export declare function parseUtc(options: ParseOptions, input: unknown): Date;
|
|
165
|
+
/**
|
|
166
|
+
* Converts an Esri-style date format constant (e.g. "short-date-short-time") to
|
|
167
|
+
* a format string that can be used with {@link format} and {@link parse}.
|
|
168
|
+
*
|
|
169
|
+
* @param format The Esri-style format constant to convert.
|
|
170
|
+
*/
|
|
171
|
+
export declare function esriFormatToGeocortexFormat(format: string): string;
|
|
172
|
+
/**
|
|
173
|
+
* Checks that a given time zone is valid.
|
|
174
|
+
*
|
|
175
|
+
* @param timeZone The IANA tz database identifier of the target time zone, e.g.
|
|
176
|
+
* "America/Vancouver", "Pacific/Fiji". See http://www.iana.org/time-zones and
|
|
177
|
+
* {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones}.
|
|
178
|
+
* @returns True if the time zone is valid and false if not.
|
|
179
|
+
*/
|
|
180
|
+
export declare function isValidTimeZone(timeZone: string): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Properties that can be passed into the constructor for
|
|
183
|
+
* {@link utilities/format/date!DateFormatter}.
|
|
184
|
+
*/
|
|
185
|
+
export interface DateFormatterProperties extends DateSettings {
|
|
186
|
+
/**
|
|
187
|
+
* The locale to use when formatting & parsing the number. If not specified,
|
|
188
|
+
* the current locale is used (see locale module).
|
|
189
|
+
*/
|
|
190
|
+
locale?: string;
|
|
191
|
+
/**
|
|
192
|
+
* The time zone of the date being formatted.
|
|
193
|
+
*/
|
|
194
|
+
timeZone?: string;
|
|
195
|
+
/**
|
|
196
|
+
* The time zone of the date being parsed.
|
|
197
|
+
*/
|
|
198
|
+
parseTimeZone?: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A helper class for formatting and parsing dates.
|
|
202
|
+
*/
|
|
203
|
+
export declare class DateFormatter extends SerializableBase<DateFormatterProperties> implements DateSettings {
|
|
204
|
+
/**
|
|
205
|
+
* @inheritDoc
|
|
206
|
+
*/
|
|
207
|
+
get defaultFormat(): string;
|
|
208
|
+
/**
|
|
209
|
+
* @inheritDoc
|
|
210
|
+
*/
|
|
211
|
+
set defaultFormat(value: string);
|
|
212
|
+
/**
|
|
213
|
+
* @inheritDoc
|
|
214
|
+
*/
|
|
215
|
+
defaultParseFormat: string;
|
|
216
|
+
/**
|
|
217
|
+
* The locale to use when formatting & parsing the number. If not specified,
|
|
218
|
+
* the current locale is used (see locale module).
|
|
219
|
+
*/
|
|
220
|
+
locale: string;
|
|
221
|
+
/**
|
|
222
|
+
* The time zone of the date being formatted.
|
|
223
|
+
*/
|
|
224
|
+
get timeZone(): string;
|
|
225
|
+
set timeZone(value: string);
|
|
226
|
+
/**
|
|
227
|
+
* The time zone of the date being parsed.
|
|
228
|
+
*/
|
|
229
|
+
get parseTimeZone(): string;
|
|
230
|
+
set parseTimeZone(value: string);
|
|
231
|
+
private _timeZone;
|
|
232
|
+
private _parseTimeZone;
|
|
233
|
+
private _defaultFormat;
|
|
234
|
+
/**
|
|
235
|
+
* Formats a date for display.
|
|
236
|
+
*
|
|
237
|
+
* @param date The date to format.
|
|
238
|
+
*/
|
|
239
|
+
format(date: Date): string;
|
|
240
|
+
/**
|
|
241
|
+
* Formats a date for display.
|
|
242
|
+
*
|
|
243
|
+
* @param date The date to format.
|
|
244
|
+
* @param format The format for presenting dates. One of the
|
|
245
|
+
* {@link utilities/format/formats!DateFormat} constants, or a custom
|
|
246
|
+
* format string. The format string syntax is similar to
|
|
247
|
+
* {@link https://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx|this},
|
|
248
|
+
* with the following exceptions:
|
|
249
|
+
*
|
|
250
|
+
* - "/", and ":" are treated as literal characters.
|
|
251
|
+
* - "y" is treated as "yy", and "yyy" is treated as "yyyy".
|
|
252
|
+
* - "z" and "zz" and "zzz" are treated as the UTC offset
|
|
253
|
+
* - "t" is treated the same as "tt".
|
|
254
|
+
* - "F", "FF", "FFF" etc. will behave the same as "f", "ff", "fff", etc.
|
|
255
|
+
* Additionally, a maximum of 3 digits (milliseconds) is supported.
|
|
256
|
+
* Longer formatters like "fffff" are truncated to 3 digits, rather
|
|
257
|
+
* than padded with zeros.
|
|
258
|
+
* - "K" is not supported at all and will be ignored. If not specified, it
|
|
259
|
+
* will default to DATE_TIME_SHORT.
|
|
260
|
+
*/
|
|
261
|
+
format(format: string, date: Date): string;
|
|
262
|
+
/**
|
|
263
|
+
* Formats a date for display.
|
|
264
|
+
*
|
|
265
|
+
* @param date The date to format.
|
|
266
|
+
* @param options Options that control how the date is formatted.
|
|
267
|
+
*/
|
|
268
|
+
format(options: FormatOptions, date: Date): string;
|
|
269
|
+
/**
|
|
270
|
+
* Parses a value into a Date object. The input is assumed to be in local
|
|
271
|
+
* time, unless it's a timestamp..
|
|
272
|
+
*
|
|
273
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
274
|
+
* (always assumed to be UTC unless timezone is specified).
|
|
275
|
+
* @returns A Date object corresponding to the input, which might be an
|
|
276
|
+
* Invalid Date (i.e. getTime() will be NaN).
|
|
277
|
+
*/
|
|
278
|
+
parse(input: unknown): Date;
|
|
279
|
+
/**
|
|
280
|
+
* Parses a value into a Date object. The input is assumed to be in local
|
|
281
|
+
* time, unless it's a timestamp..
|
|
282
|
+
*
|
|
283
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
284
|
+
* (always assumed to be UTC unless timezone is specified).
|
|
285
|
+
* @param format See {@link ParseOptions.format}.
|
|
286
|
+
* @returns A Date object corresponding to the input, which might be an
|
|
287
|
+
* Invalid Date (i.e. getTime() will be NaN).
|
|
288
|
+
*/
|
|
289
|
+
parse(format: string | string[], input: unknown): Date;
|
|
290
|
+
/**
|
|
291
|
+
* Parses a value into a Date object. The input is assumed to be in local
|
|
292
|
+
* time, unless it's a timestamp.
|
|
293
|
+
*
|
|
294
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
295
|
+
* (always assumed to be UTC unless timezone is specified).
|
|
296
|
+
* @param options The options to use for parsing.
|
|
297
|
+
* @returns A Date object corresponding to the input, which might be an
|
|
298
|
+
* Invalid Date (i.e. getTime() will be NaN).
|
|
299
|
+
*/
|
|
300
|
+
parse(options: ParseOptions, input: unknown): Date;
|
|
301
|
+
/**
|
|
302
|
+
* Parses a value into a Date object. The input is assumed to be in UTC.
|
|
303
|
+
*
|
|
304
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
305
|
+
* (always assumed to be UTC even if timezone is specified).
|
|
306
|
+
* @returns A Date object corresponding to the input, which might be an
|
|
307
|
+
* Invalid Date (i.e. getTime() will be NaN).
|
|
308
|
+
*/
|
|
309
|
+
parseUtc(input: unknown | undefined): Date;
|
|
310
|
+
/**
|
|
311
|
+
* Parses a value into a Date object. The input is assumed to be in UTC.
|
|
312
|
+
*
|
|
313
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
314
|
+
* (always assumed to be UTC even if timezone is specified).
|
|
315
|
+
* @param format See {@link ParseOptions.format}.
|
|
316
|
+
* @returns A Date object corresponding to the input, which might be an
|
|
317
|
+
* Invalid Date (i.e. getTime() will be NaN).
|
|
318
|
+
*/
|
|
319
|
+
parseUtc(format: string | string[], input: unknown): Date;
|
|
320
|
+
/**
|
|
321
|
+
* Parses a value into a Date object. The input is assumed to be in UTC.
|
|
322
|
+
*
|
|
323
|
+
* @param input The input to parse. Numbers are treated as UNIX timestamps
|
|
324
|
+
* (always assumed to be UTC even if timezone is specified).
|
|
325
|
+
* @param options The options to use for parsing.
|
|
326
|
+
* @returns A Date object corresponding to the input, which might be an
|
|
327
|
+
* Invalid Date (i.e. getTime() will be NaN).
|
|
328
|
+
*/
|
|
329
|
+
parseUtc(options: ParseOptions, input: unknown): Date;
|
|
330
|
+
protected _getSerializableProperties(): PropertyDefs<DateFormatterProperties>;
|
|
331
|
+
private _parse;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Default settings used for formatting and parsing dates.
|
|
335
|
+
*/
|
|
336
|
+
export declare const settings: DateSettings;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__decorate as e}from"tslib";import{DateTime as t}from"luxon";import{get as r,INVARIANT as o}from"../../locale.js";import{serializable as n,SerializableBase as s}from"../../support/Serializable.js";import{checkArg as a}from"../checkArg.js";import{isNumeric as i}from"../number.js";import{settings as m}from"./FormatSettings.js";import{gcxDateTimeFormatToLuxonFormat as y}from"./_utils.js";import{DateFormat as d}from"./formats.js";import{parse as l}from"./number.js";export const ERR_TIME_ZONE_INVALID=e=>`Unrecognized time zone ${e}. Make sure it is a valid IANA time zone name, e.g. "America/Vancouver".`;export const DEFAULT_PARSING_FORMATS=[d.ISO_8601,d.DATE_TIME_SHORT,d.DATE_TIME_LONG,d.DATE_SHORT,d.DATE_LONG];export const INVALID_DATE=new Date(NaN);export function isValid(e){return e&&!isNaN(e.getTime())}export function format(...e){return h.format(...e)}export function parse(...e){return h.parse(...e)}export function parseUtc(...e){return h.parseUtc(...e)}export function esriFormatToGeocortexFormat(e){if(e)switch(e){case"short-date":return"d";case"short-date-short-time":return"εσρι M/d/yyyy h:mm tt";case"short-date-short-time-24":return"εσρι M/d/yyyy H:mm";case"short-date-long-time":return"εσρι M/d/yyyy h:mm:ss tt";case"short-date-long-time-24":return"εσρι M/d/yyyy H:mm:ss";case"short-date-le":return"d/M/yyyy";case"short-date-le-short-time":return"d/M/yyyy h:mm tt";case"short-date-le-short-time-24":return"d/M/yyyy H:mm";case"short-date-le-long-time":return"d/M/yyyy h:mm:ss tt";case"short-date-le-long-time-24":return"d/M/yyyy H:mm:ss";case"long-month-day-year":return"D";case"long-month-day-year-short-time":return"εσρι MMMM d yyyy h:mm tt";case"long-month-day-year-short-time-24":return"εσρι MMMM d yyyy H:mm";case"long-month-day-year-long-time":return"εσρι MMMM d yyyy h:mm:ss tt";case"long-month-day-year-long-time-24":return"εσρι MMMM d yyyy H:mm:ss";case"day-short-month-year":return"d MMM yyyy";case"day-short-month-year-short-time":return"d MMM yyyy h:mm tt";case"day-short-month-year-short-time-24":return"d MMM yyyy H:mm";case"day-short-month-year-long-time":return"d MMM yyyy h:mm:ss tt";case"day-short-month-year-long-time-24":return"d MMM yyyy H:mm:ss";case"long-date":return"dddd, MMMM d, yyyy";case"long-date-short-time":return"dddd, MMMM d, yyyy h:mm tt";case"long-date-short-time-24":return"dddd, MMMM d, yyyy H:mm";case"long-date-long-time":return"dddd, MMMM d, yyyy H:mm tt";case"long-date-long-time-24":return"dddd, MMMM d, yyyy H:mm:ss";case"long-month-year":return"MMMM yyyy";case"short-month-year":return"MMM yyyy";case"year":return"yyyy";default:throw new Error(`Unrecognized date format constant: ${e}`)}}function u(e,r){const o=t.fromMillis(e).setZone("UTC").toISO({includeOffset:!1});return t.fromISO(o,{zone:r}).valueOf()}export function isValidTimeZone(e){try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch{return!1}}let M=class extends s{get defaultFormat(){return this._defaultFormat}set defaultFormat(e){this._defaultFormat=e}defaultParseFormat;locale;get timeZone(){return this._timeZone}set timeZone(e){a("timezone",e).satisfies(isValidTimeZone,ERR_TIME_ZONE_INVALID(e)),this._timeZone=e}get parseTimeZone(){return this._parseTimeZone}set parseTimeZone(e){a("timezone",e).satisfies(isValidTimeZone,ERR_TIME_ZONE_INVALID(e)),this._parseTimeZone=e}_timeZone;_parseTimeZone;_defaultFormat;format(...e){let n,s;if(1===arguments.length?(n=e[0],s={}):arguments.length>=2&&(n=e[1],s="string"==typeof e[0]?{format:e[0]}:e[0],a("options",s).isNotMissing()),!n)return"";if(s.timeZone&&a("timezone",s.timeZone).satisfies(isValidTimeZone,ERR_TIME_ZONE_INVALID(s.timeZone)),!n?.getTime||isNaN(n.getTime()))return"";const i=s.timeZone??this.timeZone;let m=s.locale??this.locale??r();m===o&&(m="en");const l=s.format??this.defaultFormat??d.DEFAULT,u=y(l,s.isDateOnly);let M=t.fromJSDate(n).setLocale(m);return i&&(M=M.setZone(i)),"ISO-8601"===u?M.toISO():M.toFormat(u)}parse(...e){return this._parse(!1,...e)}parseUtc(...e){return this._parse(!0,...e)}_getSerializableProperties(){return{defaultFormat:"initial",defaultParseFormat:"initial",locale:"initial",timeZone:"initial",parseTimeZone:"initial"}}_parse(e,...o){let n,s;if(1===o.length?(n=o[0],s={}):o.length>=2&&(n=o[1],s="string"==typeof o[0]||Array.isArray(o[0])?{format:o[0]}:o[0]),s.timeZone&&a("timezone",s.timeZone).satisfies(isValidTimeZone,ERR_TIME_ZONE_INVALID(s.timeZone)),n instanceof Date)return n;if("number"==typeof n){const t=s.timeZone&&!e?u(n,s.timeZone):n;return new Date(t)}if("string"!=typeof n)return INVALID_DATE;let{format:m}=s;if(void 0===m&&i(n)){let t=l(n);return t=s.timeZone&&!e?u(t,s.timeZone):t,new Date(t)}m=m??this.defaultParseFormat??DEFAULT_PARSING_FORMATS;const d=[].concat(m),M=s.timeZone??this.parseTimeZone,c={locale:s.locale??this.locale??r(),zone:e?"UTC":M,setZone:!0};for(const e of d){const r=y(e,s.isDateOnly),o="ISO-8601"===r?t.fromISO(n,c):t.fromFormat(n,r,c);if(o.isValid)return o.toJSDate()}return INVALID_DATE}};M=e([n],M);export{M as DateFormatter};let c=class extends M{get defaultFormat(){return m.dateFormat}set defaultFormat(e){m.dateFormat=e}get timeZone(){return m.timeZone}set timeZone(e){m.timeZone=e}};c=e([n],c);const h=new c;export const settings=h;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-defined format specifiers for use with
|
|
3
|
+
* {@link utilities/format/date!format}.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum DateFormat {
|
|
6
|
+
/**
|
|
7
|
+
* A localized representation of a date (e.g. "09/04/1986" for en-US
|
|
8
|
+
* locale).
|
|
9
|
+
*/
|
|
10
|
+
DATE_SHORT = "d",
|
|
11
|
+
/**
|
|
12
|
+
* A localized long representation of a date (e.g. "September 4 1986" for
|
|
13
|
+
* en-US locale).
|
|
14
|
+
*/
|
|
15
|
+
DATE_LONG = "D",
|
|
16
|
+
/**
|
|
17
|
+
* A localized short representation of the time (e.g. "8:30 PM" for en-US
|
|
18
|
+
* locale).
|
|
19
|
+
*/
|
|
20
|
+
TIME_SHORT = "t",
|
|
21
|
+
/**
|
|
22
|
+
* A localized representation of the time including seconds (e.g. "8:30:25
|
|
23
|
+
* PM" for en-US locale).
|
|
24
|
+
*/
|
|
25
|
+
TIME_LONG = "T",
|
|
26
|
+
/**
|
|
27
|
+
* A localized representation of date and time (e.g. "Sep 4 1986 8:30 PM"
|
|
28
|
+
* for en-US locale).
|
|
29
|
+
*/
|
|
30
|
+
DATE_TIME_SHORT = "g",
|
|
31
|
+
/**
|
|
32
|
+
* A localized long representation of date and time (e.g. "September 4 1986
|
|
33
|
+
* 8:30 PM" for en-US locale).
|
|
34
|
+
*/
|
|
35
|
+
DATE_TIME_LONG = "G",
|
|
36
|
+
/**
|
|
37
|
+
* A localized full representation of date and time, including day of week
|
|
38
|
+
* (e.g. "Thursday, September 4 1986 8:30 PM" for en-US locale).
|
|
39
|
+
*/
|
|
40
|
+
FULL = "f",
|
|
41
|
+
/**
|
|
42
|
+
* The date and time in ISO-8601 format (e.g. "2014-09-08T08:02:17-05:00").
|
|
43
|
+
* Invariant.
|
|
44
|
+
*/
|
|
45
|
+
ISO_8601 = "u",
|
|
46
|
+
/**
|
|
47
|
+
* An invariant representation of a date. Guarantees that the date can be
|
|
48
|
+
* parsed back into the same date, regardless of locale. Equivalent to
|
|
49
|
+
* ISO-8601.
|
|
50
|
+
*/
|
|
51
|
+
ROUND_TRIP = "u",
|
|
52
|
+
/**
|
|
53
|
+
* The default representation for date values (equivalent to
|
|
54
|
+
* DATE_TIME_SHORT).
|
|
55
|
+
*/
|
|
56
|
+
DEFAULT = "g"
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pre-defined format specifiers for use with
|
|
60
|
+
* {@link utilities/format/number!format}.
|
|
61
|
+
*/
|
|
62
|
+
export declare enum NumberFormat {
|
|
63
|
+
/**
|
|
64
|
+
* A localized representation of a number with a decimal separator and group
|
|
65
|
+
* separators (e.g. "12,345.67", "-42" for en-US locale).
|
|
66
|
+
*/
|
|
67
|
+
NUMBER = "n",
|
|
68
|
+
/**
|
|
69
|
+
* A localized representation of a number with a decimal separator (e.g.
|
|
70
|
+
* "12345.67", "-42" for en-US locale).
|
|
71
|
+
*/
|
|
72
|
+
FIXED_POINT = "f",
|
|
73
|
+
/**
|
|
74
|
+
* A localized representation of a monetary amount in a specific currency
|
|
75
|
+
* (e.g. "$123.45" for USD, "£123.45" for GBP for en-US locale).
|
|
76
|
+
*/
|
|
77
|
+
CURRENCY = "c",
|
|
78
|
+
/**
|
|
79
|
+
* Same as CURRENCY, except that negative values are displayed in
|
|
80
|
+
* parentheses instead of using a "-" sign.
|
|
81
|
+
*/
|
|
82
|
+
ACCOUNTING = "a",
|
|
83
|
+
/**
|
|
84
|
+
* A localized representation of a percentage (e.g. 0.99 -> "99%" in the
|
|
85
|
+
* en-US locale).
|
|
86
|
+
*/
|
|
87
|
+
PERCENT = "p",
|
|
88
|
+
/**
|
|
89
|
+
* An invariant representation of a number (e.g. "12345.67"). Guarantees
|
|
90
|
+
* that the number can be parsed back into the same number, regardless of
|
|
91
|
+
* locale.
|
|
92
|
+
*/
|
|
93
|
+
ROUND_TRIP = "r",
|
|
94
|
+
/**
|
|
95
|
+
* The default representation for number values (equivalent to FIXED_POINT).
|
|
96
|
+
*/
|
|
97
|
+
DEFAULT = "f"
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Pre-defined format specifiers for use with
|
|
101
|
+
* {@link utilities/format/time!format}.
|
|
102
|
+
*/
|
|
103
|
+
export declare enum TimeFormat {
|
|
104
|
+
/**
|
|
105
|
+
* A localized short representation of the time (e.g. "8:30 PM" for en-US
|
|
106
|
+
* locale).
|
|
107
|
+
*/
|
|
108
|
+
TIME_SHORT = "t",
|
|
109
|
+
/**
|
|
110
|
+
* A localized representation of the time including seconds (e.g. "8:30:25
|
|
111
|
+
* PM" for en-US locale).
|
|
112
|
+
*/
|
|
113
|
+
TIME_LONG = "T",
|
|
114
|
+
/**
|
|
115
|
+
* The time in ISO-8601 format (e.g. "08:02:17"). Invariant.
|
|
116
|
+
*/
|
|
117
|
+
ISO_8601 = "u",
|
|
118
|
+
/**
|
|
119
|
+
* An invariant representation of a time. Guarantees that the time can be
|
|
120
|
+
* parsed back into the same time. Equivalent to ISO-8601.
|
|
121
|
+
*/
|
|
122
|
+
ROUND_TRIP = "u",
|
|
123
|
+
/**
|
|
124
|
+
* The default representation for time values (equivalent to TIME_SHORT).
|
|
125
|
+
*/
|
|
126
|
+
DEFAULT = "t"
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var DateFormat;!function(T){T.DATE_SHORT="d",T.DATE_LONG="D",T.TIME_SHORT="t",T.TIME_LONG="T",T.DATE_TIME_SHORT="g",T.DATE_TIME_LONG="G",T.FULL="f",T.ISO_8601="u",T.ROUND_TRIP="u",T.DEFAULT="g"}(DateFormat||(DateFormat={}));export var NumberFormat;!function(T){T.NUMBER="n",T.FIXED_POINT="f",T.CURRENCY="c",T.ACCOUNTING="a",T.PERCENT="p",T.ROUND_TRIP="r",T.DEFAULT="f"}(NumberFormat||(NumberFormat={}));export var TimeFormat;!function(T){T.TIME_SHORT="t",T.TIME_LONG="T",T.ISO_8601="u",T.ROUND_TRIP="u",T.DEFAULT="t"}(TimeFormat||(TimeFormat={}));
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { PropertyDefs } from "../../support/Serializable.js";
|
|
2
|
+
import { SerializableBase } from "../../support/Serializable.js";
|
|
3
|
+
/**
|
|
4
|
+
* Default settings that affect how numbers are formatted and parsed.
|
|
5
|
+
*/
|
|
6
|
+
export interface NumberSettings {
|
|
7
|
+
/**
|
|
8
|
+
* The default format for formatting numbers. See
|
|
9
|
+
* {@link utilities/format/number!NumberFormatter.format}.
|
|
10
|
+
*/
|
|
11
|
+
defaultFormat?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Either a single format, or one of several possible formats that the input
|
|
14
|
+
* is expected to be in. If specified, the input must _exactly_ match. The
|
|
15
|
+
* syntax is the same as for
|
|
16
|
+
* {@link utilities/format/number!NumberFormatter.format}.
|
|
17
|
+
*/
|
|
18
|
+
defaultParseFormat?: string | string[];
|
|
19
|
+
/**
|
|
20
|
+
* The 3-letter ISO 4217 currency code (e.g "USD", "CAD"). Required when
|
|
21
|
+
* formatting a number using NumberFormat.CURRENCY or
|
|
22
|
+
* NumberFormat.ACCOUNTING.
|
|
23
|
+
*/
|
|
24
|
+
currency?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The number of digits to show after the decimal point. If unspecified, an
|
|
27
|
+
* appropriate value is determined based on the locale and currency.
|
|
28
|
+
*/
|
|
29
|
+
fractionalDigits?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options supported by {@link format}.
|
|
33
|
+
*/
|
|
34
|
+
export interface FormatOptions {
|
|
35
|
+
/**
|
|
36
|
+
* The locale to use when formatting the number. If not specified, the
|
|
37
|
+
* current locale is used (see locale module).
|
|
38
|
+
*/
|
|
39
|
+
locale?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The number format. See
|
|
42
|
+
* {@link utilities/format/number!NumberFormatter.format}.
|
|
43
|
+
*/
|
|
44
|
+
format?: string;
|
|
45
|
+
/**
|
|
46
|
+
* See {@link NumberSettings.currency}.
|
|
47
|
+
*/
|
|
48
|
+
currency?: string;
|
|
49
|
+
/**
|
|
50
|
+
* See {@link NumberSettings.fractionalDigits}.
|
|
51
|
+
*/
|
|
52
|
+
fractionalDigits?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options supported by {@link parse}.
|
|
56
|
+
*/
|
|
57
|
+
export interface ParseOptions {
|
|
58
|
+
/**
|
|
59
|
+
* The locale to use when parsing the number. If not specified, the current
|
|
60
|
+
* locale is used (see locale module).
|
|
61
|
+
*/
|
|
62
|
+
locale?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Either a single format, or one of several possible formats that the input
|
|
65
|
+
* is expected to be in. If specified, the input must _exactly_ match. See
|
|
66
|
+
* {@link NumberFormatter.format}.
|
|
67
|
+
*/
|
|
68
|
+
format?: string | string[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Formats a number for display in the current locale.
|
|
72
|
+
*
|
|
73
|
+
* @param num The number to format.
|
|
74
|
+
*/
|
|
75
|
+
export declare function format(num: number): string;
|
|
76
|
+
/**
|
|
77
|
+
* Formats a number for display.
|
|
78
|
+
*
|
|
79
|
+
* @param format See {@link utilities/format/number!NumberFormatter.format}.
|
|
80
|
+
* @param num The number to format.
|
|
81
|
+
*/
|
|
82
|
+
export declare function format(format: string, num: number): string;
|
|
83
|
+
/**
|
|
84
|
+
* Formats a number for display.
|
|
85
|
+
*
|
|
86
|
+
* @param options Specifies the format settings to use.
|
|
87
|
+
* @param num The number to format.
|
|
88
|
+
*/
|
|
89
|
+
export declare function format(options: FormatOptions, num: number): string;
|
|
90
|
+
/**
|
|
91
|
+
* Parses a value into a number.
|
|
92
|
+
*
|
|
93
|
+
* @param input The input to parse.
|
|
94
|
+
* @returns A number corresponding to the input, or NaN if the input can't be
|
|
95
|
+
* parsed.
|
|
96
|
+
*/
|
|
97
|
+
export declare function parse(input: unknown): number;
|
|
98
|
+
/**
|
|
99
|
+
* Parses a value into a number.
|
|
100
|
+
*
|
|
101
|
+
* @param format See {@link ParseOptions.format}.
|
|
102
|
+
* @param input The input to parse.
|
|
103
|
+
* @returns A number corresponding to the input, or NaN if the input can't be
|
|
104
|
+
* parsed.
|
|
105
|
+
*/
|
|
106
|
+
export declare function parse(format: string | string[], input: unknown): number;
|
|
107
|
+
/**
|
|
108
|
+
* Parses a value into a number.
|
|
109
|
+
*
|
|
110
|
+
* @param options The options to use for parsing.
|
|
111
|
+
* @param input The input to parse.
|
|
112
|
+
* @returns A number corresponding to the input, or NaN if the input can't be
|
|
113
|
+
* parsed.
|
|
114
|
+
*/
|
|
115
|
+
export declare function parse(options: ParseOptions, input: unknown): number;
|
|
116
|
+
/**
|
|
117
|
+
* Properties that can be passed into the constructor for
|
|
118
|
+
* {@link utilities/format/number!NumberFormatter}.
|
|
119
|
+
*/
|
|
120
|
+
export interface NumberFormatterProperties extends NumberSettings {
|
|
121
|
+
/**
|
|
122
|
+
* The locale to use when formatting & parsing the number. If not specified,
|
|
123
|
+
* the current locale is used (see locale module).
|
|
124
|
+
*/
|
|
125
|
+
locale?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A helper class for formatting and parsing numbers.
|
|
129
|
+
*/
|
|
130
|
+
export declare class NumberFormatter extends SerializableBase<NumberFormatterProperties> implements NumberSettings {
|
|
131
|
+
/**
|
|
132
|
+
* @inheritDoc
|
|
133
|
+
*/
|
|
134
|
+
get defaultFormat(): string;
|
|
135
|
+
set defaultFormat(defaultFormat: string);
|
|
136
|
+
/**
|
|
137
|
+
* @inheritDoc
|
|
138
|
+
*/
|
|
139
|
+
get defaultParseFormat(): string;
|
|
140
|
+
set defaultParseFormat(defaultParseFormat: string);
|
|
141
|
+
/**
|
|
142
|
+
* @inheritDoc
|
|
143
|
+
*/
|
|
144
|
+
get currency(): string;
|
|
145
|
+
set currency(currency: string);
|
|
146
|
+
/**
|
|
147
|
+
* @inheritDoc
|
|
148
|
+
*/
|
|
149
|
+
get fractionalDigits(): number;
|
|
150
|
+
set fractionalDigits(fractionalDigits: number);
|
|
151
|
+
/**
|
|
152
|
+
* The locale to use when formatting & parsing the number. If not specified,
|
|
153
|
+
* the current locale is used (see locale module).
|
|
154
|
+
*/
|
|
155
|
+
locale: string;
|
|
156
|
+
private _defaultFormat;
|
|
157
|
+
private _defaultParseFormat;
|
|
158
|
+
private _currency;
|
|
159
|
+
private _fractionalDigits;
|
|
160
|
+
/**
|
|
161
|
+
* See {@link format}.
|
|
162
|
+
*/
|
|
163
|
+
format(format: string, num: number): string;
|
|
164
|
+
format(options: FormatOptions, num: number): string;
|
|
165
|
+
format(num: number): string;
|
|
166
|
+
/**
|
|
167
|
+
* See {@link parse}.
|
|
168
|
+
*/
|
|
169
|
+
parse(input: unknown): number;
|
|
170
|
+
parse(format: string | string[], input: unknown): number;
|
|
171
|
+
parse(options: ParseOptions, input: unknown): number;
|
|
172
|
+
protected _getSerializableProperties(): PropertyDefs<NumberFormatterProperties>;
|
|
173
|
+
/**
|
|
174
|
+
* Converts a format string accepted by formatNumber() to formatter
|
|
175
|
+
* function.
|
|
176
|
+
*
|
|
177
|
+
* @param inputLocales The locale.
|
|
178
|
+
* @param format The format to use.
|
|
179
|
+
* @param defaultOptions Options that control how values are formatted.
|
|
180
|
+
*/
|
|
181
|
+
private _createNumberFormatter;
|
|
182
|
+
/**
|
|
183
|
+
* Create a numeric parser function for a set of locales.
|
|
184
|
+
*
|
|
185
|
+
* @param inputLocales An ordered array of locales to be used for parsing
|
|
186
|
+
* sorted in order of precedence.
|
|
187
|
+
*/
|
|
188
|
+
private _createNumberParser;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Default settings used for formatting and parsing numbers.
|
|
192
|
+
*/
|
|
193
|
+
export declare const settings: NumberSettings;
|