@wordpress/date 5.32.0 → 5.32.1-next.b8c8708f3.0

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.
@@ -1,104 +1,93 @@
1
- /**
2
- * External dependencies
3
- */
4
-
5
- import momentLib from 'moment';
6
- import 'moment-timezone/moment-timezone';
7
- import 'moment-timezone/moment-timezone-utils';
8
-
9
- /**
10
- * WordPress dependencies
11
- */
12
- import deprecated from '@wordpress/deprecated';
13
- /**
14
- * Internal dependencies
15
- */
16
-
17
- export * from './types';
18
- const WP_ZONE = 'WP';
19
-
20
- // This regular expression tests positive for UTC offsets as described in ISO 8601.
21
- // See: https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
1
+ import momentLib from "moment";
2
+ import "moment-timezone/moment-timezone";
3
+ import "moment-timezone/moment-timezone-utils";
4
+ import deprecated from "@wordpress/deprecated";
5
+ export * from "./types";
6
+ const WP_ZONE = "WP";
22
7
  const VALID_UTC_OFFSET = /^[+-][0-1][0-9](:?[0-9][0-9])?$/;
23
-
24
- // Changes made here will likely need to be synced with Core in the file
25
- // src/wp-includes/script-loader.php in `wp_default_packages_inline_scripts()`.
26
8
  let settings = {
27
9
  l10n: {
28
- locale: 'en',
29
- months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
30
- monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
31
- weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
32
- weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
33
- meridiem: {
34
- am: 'am',
35
- pm: 'pm',
36
- AM: 'AM',
37
- PM: 'PM'
38
- },
10
+ locale: "en",
11
+ months: [
12
+ "January",
13
+ "February",
14
+ "March",
15
+ "April",
16
+ "May",
17
+ "June",
18
+ "July",
19
+ "August",
20
+ "September",
21
+ "October",
22
+ "November",
23
+ "December"
24
+ ],
25
+ monthsShort: [
26
+ "Jan",
27
+ "Feb",
28
+ "Mar",
29
+ "Apr",
30
+ "May",
31
+ "Jun",
32
+ "Jul",
33
+ "Aug",
34
+ "Sep",
35
+ "Oct",
36
+ "Nov",
37
+ "Dec"
38
+ ],
39
+ weekdays: [
40
+ "Sunday",
41
+ "Monday",
42
+ "Tuesday",
43
+ "Wednesday",
44
+ "Thursday",
45
+ "Friday",
46
+ "Saturday"
47
+ ],
48
+ weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
49
+ meridiem: { am: "am", pm: "pm", AM: "AM", PM: "PM" },
39
50
  relative: {
40
- future: '%s from now',
41
- past: '%s ago',
42
- s: 'a few seconds',
43
- ss: '%d seconds',
44
- m: 'a minute',
45
- mm: '%d minutes',
46
- h: 'an hour',
47
- hh: '%d hours',
48
- d: 'a day',
49
- dd: '%d days',
50
- M: 'a month',
51
- MM: '%d months',
52
- y: 'a year',
53
- yy: '%d years'
51
+ future: "%s from now",
52
+ past: "%s ago",
53
+ s: "a few seconds",
54
+ ss: "%d seconds",
55
+ m: "a minute",
56
+ mm: "%d minutes",
57
+ h: "an hour",
58
+ hh: "%d hours",
59
+ d: "a day",
60
+ dd: "%d days",
61
+ M: "a month",
62
+ MM: "%d months",
63
+ y: "a year",
64
+ yy: "%d years"
54
65
  },
55
66
  startOfWeek: 0
56
67
  },
57
68
  formats: {
58
- time: 'g: i a',
59
- date: 'F j, Y',
60
- datetime: 'F j, Y g: i a',
61
- datetimeAbbreviated: 'M j, Y g: i a'
69
+ time: "g: i a",
70
+ date: "F j, Y",
71
+ datetime: "F j, Y g: i a",
72
+ datetimeAbbreviated: "M j, Y g: i a"
62
73
  },
63
- timezone: {
64
- offset: '0',
65
- offsetFormatted: '0',
66
- string: '',
67
- abbr: ''
68
- }
74
+ timezone: { offset: "0", offsetFormatted: "0", string: "", abbr: "" }
69
75
  };
70
-
71
- /**
72
- * Adds a locale to moment, using the format supplied by `wp_localize_script()`.
73
- *
74
- * @param dateSettings Settings, including locale data.
75
- */
76
- export function setSettings(dateSettings) {
76
+ function setSettings(dateSettings) {
77
77
  settings = dateSettings;
78
78
  setupWPTimezone();
79
-
80
- // Does moment already have a locale with the right name?
81
79
  if (momentLib.locales().includes(dateSettings.l10n.locale)) {
82
- // Is that locale misconfigured, e.g. because we are on a site running
83
- // WordPress < 6.0?
84
- if (momentLib.localeData(dateSettings.l10n.locale).longDateFormat('LTS') === null) {
85
- // Delete the misconfigured locale.
86
- // @ts-ignore Type definitions are incorrect - null is permitted.
80
+ if (momentLib.localeData(dateSettings.l10n.locale).longDateFormat("LTS") === null) {
87
81
  momentLib.defineLocale(dateSettings.l10n.locale, null);
88
82
  } else {
89
- // We have a properly configured locale, so no need to create one.
90
83
  return;
91
84
  }
92
85
  }
93
-
94
- // defineLocale() will modify the current locale, so back it up.
95
86
  const currentLocale = momentLib.locale();
96
-
97
- // Create locale.
98
87
  momentLib.defineLocale(dateSettings.l10n.locale, {
99
88
  // Inherit anything missing from English. We don't load
100
89
  // moment-with-locales.js so English is all there is.
101
- parentLocale: 'en',
90
+ parentLocale: "en",
102
91
  months: dateSettings.l10n.months,
103
92
  monthsShort: dateSettings.l10n.monthsShort,
104
93
  weekdays: dateSettings.l10n.weekdays,
@@ -111,100 +100,60 @@ export function setSettings(dateSettings) {
111
100
  },
112
101
  longDateFormat: {
113
102
  LT: dateSettings.formats.time,
114
- LTS: momentLib.localeData('en').longDateFormat('LTS'),
115
- L: momentLib.localeData('en').longDateFormat('L'),
103
+ LTS: momentLib.localeData("en").longDateFormat("LTS"),
104
+ L: momentLib.localeData("en").longDateFormat("L"),
116
105
  LL: dateSettings.formats.date,
117
106
  LLL: dateSettings.formats.datetime,
118
- LLLL: momentLib.localeData('en').longDateFormat('LLLL')
107
+ LLLL: momentLib.localeData("en").longDateFormat("LLLL")
119
108
  },
120
109
  // From human_time_diff?
121
110
  // Set to `(number, withoutSuffix, key, isFuture) => {}` instead.
122
111
  relativeTime: dateSettings.l10n.relative
123
112
  });
124
-
125
- // Restore the locale to what it was.
126
113
  momentLib.locale(currentLocale);
127
114
  }
128
-
129
- /**
130
- * Returns the currently defined date settings.
131
- *
132
- * @return {DateSettings} Settings, including locale data.
133
- */
134
- export function getSettings() {
115
+ function getSettings() {
135
116
  return settings;
136
117
  }
137
-
138
- /**
139
- * Returns the currently defined date settings.
140
- *
141
- * @deprecated
142
- * @return {DateSettings} Settings, including locale data.
143
- */
144
- export function __experimentalGetSettings() {
145
- deprecated('wp.date.__experimentalGetSettings', {
146
- since: '6.1',
147
- alternative: 'wp.date.getSettings'
118
+ function __experimentalGetSettings() {
119
+ deprecated("wp.date.__experimentalGetSettings", {
120
+ since: "6.1",
121
+ alternative: "wp.date.getSettings"
148
122
  });
149
123
  return getSettings();
150
124
  }
151
125
  function setupWPTimezone() {
152
- // Get the current timezone settings from the WP timezone string.
153
126
  const currentTimezone = momentLib.tz.zone(settings.timezone.string);
154
-
155
- // Check to see if we have a valid TZ data, if so, use it for the custom WP_ZONE timezone, otherwise just use the offset.
156
127
  if (currentTimezone) {
157
- // Create WP timezone based off settings.timezone.string. We need to include the additional data so that we
158
- // don't lose information about daylight savings time and other items.
159
- // See https://github.com/WordPress/gutenberg/pull/48083
160
- momentLib.tz.add(momentLib.tz.pack({
161
- name: WP_ZONE,
162
- abbrs: currentTimezone.abbrs,
163
- untils: currentTimezone.untils,
164
- offsets: currentTimezone.offsets
165
- }));
128
+ momentLib.tz.add(
129
+ momentLib.tz.pack({
130
+ name: WP_ZONE,
131
+ abbrs: currentTimezone.abbrs,
132
+ untils: currentTimezone.untils,
133
+ offsets: currentTimezone.offsets
134
+ })
135
+ );
166
136
  } else {
167
- // Create WP timezone based off dateSettings.
168
- momentLib.tz.add(momentLib.tz.pack({
169
- name: WP_ZONE,
170
- abbrs: [WP_ZONE],
171
- untils: [null],
172
- offsets: [-settings.timezone.offset * 60 || 0]
173
- }));
137
+ momentLib.tz.add(
138
+ momentLib.tz.pack({
139
+ name: WP_ZONE,
140
+ abbrs: [WP_ZONE],
141
+ untils: [null],
142
+ offsets: [-settings.timezone.offset * 60 || 0]
143
+ })
144
+ );
174
145
  }
175
146
  }
176
-
177
- // Date constants.
178
- /**
179
- * Number of seconds in one minute.
180
- */
181
147
  const MINUTE_IN_SECONDS = 60;
182
- /**
183
- * Number of minutes in one hour.
184
- */
185
148
  const HOUR_IN_MINUTES = 60;
186
- /**
187
- * Number of seconds in one hour.
188
- */
189
149
  const HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;
190
-
191
- /**
192
- * Map of PHP formats to Moment.js formats.
193
- *
194
- * These are used internally by {@link format}, and are either
195
- * a string representing the corresponding Moment.js format code, or a
196
- * function which returns the formatted string.
197
- *
198
- * This should only be used through {@link format}, not
199
- * directly.
200
- */
201
150
  const formatMap = {
202
151
  // Day.
203
- d: 'DD',
204
- D: 'ddd',
205
- j: 'D',
206
- l: 'dddd',
207
- N: 'E',
152
+ d: "DD",
153
+ D: "ddd",
154
+ j: "D",
155
+ l: "dddd",
156
+ N: "E",
208
157
  /**
209
158
  * Gets the ordinal suffix.
210
159
  *
@@ -213,12 +162,11 @@ const formatMap = {
213
162
  * @return Formatted date.
214
163
  */
215
164
  S(momentDate) {
216
- // Do - D.
217
- const num = momentDate.format('D');
218
- const withOrdinal = momentDate.format('Do');
219
- return withOrdinal.replace(num, '');
165
+ const num = momentDate.format("D");
166
+ const withOrdinal = momentDate.format("Do");
167
+ return withOrdinal.replace(num, "");
220
168
  },
221
- w: 'd',
169
+ w: "d",
222
170
  /**
223
171
  * Gets the day of the year (zero-indexed).
224
172
  *
@@ -227,16 +175,15 @@ const formatMap = {
227
175
  * @return Formatted date.
228
176
  */
229
177
  z(momentDate) {
230
- // DDD - 1.
231
- return (parseInt(momentDate.format('DDD'), 10) - 1).toString();
178
+ return (parseInt(momentDate.format("DDD"), 10) - 1).toString();
232
179
  },
233
180
  // Week.
234
- W: 'W',
181
+ W: "W",
235
182
  // Month.
236
- F: 'MMMM',
237
- m: 'MM',
238
- M: 'MMM',
239
- n: 'M',
183
+ F: "MMMM",
184
+ m: "MM",
185
+ M: "MMM",
186
+ n: "M",
240
187
  /**
241
188
  * Gets the days in the month.
242
189
  *
@@ -256,14 +203,14 @@ const formatMap = {
256
203
  * @return Formatted date.
257
204
  */
258
205
  L(momentDate) {
259
- return momentDate.isLeapYear() ? '1' : '0';
206
+ return momentDate.isLeapYear() ? "1" : "0";
260
207
  },
261
- o: 'GGGG',
262
- Y: 'YYYY',
263
- y: 'YY',
208
+ o: "GGGG",
209
+ Y: "YYYY",
210
+ y: "YY",
264
211
  // Time.
265
- a: 'a',
266
- A: 'A',
212
+ a: "a",
213
+ A: "A",
267
214
  /**
268
215
  * Gets the current time in Swatch Internet Time (.beats).
269
216
  *
@@ -273,21 +220,22 @@ const formatMap = {
273
220
  */
274
221
  B(momentDate) {
275
222
  const timezoned = momentLib(momentDate).utcOffset(60);
276
- const seconds = parseInt(timezoned.format('s'), 10),
277
- minutes = parseInt(timezoned.format('m'), 10),
278
- hours = parseInt(timezoned.format('H'), 10);
279
- return parseInt(((seconds + minutes * MINUTE_IN_SECONDS + hours * HOUR_IN_SECONDS) / 86.4).toString(), 10);
223
+ const seconds = parseInt(timezoned.format("s"), 10), minutes = parseInt(timezoned.format("m"), 10), hours = parseInt(timezoned.format("H"), 10);
224
+ return parseInt(
225
+ ((seconds + minutes * MINUTE_IN_SECONDS + hours * HOUR_IN_SECONDS) / 86.4).toString(),
226
+ 10
227
+ );
280
228
  },
281
- g: 'h',
282
- G: 'H',
283
- h: 'hh',
284
- H: 'HH',
285
- i: 'mm',
286
- s: 'ss',
287
- u: 'SSSSSS',
288
- v: 'SSS',
229
+ g: "h",
230
+ G: "H",
231
+ h: "hh",
232
+ H: "HH",
233
+ i: "mm",
234
+ s: "ss",
235
+ u: "SSSSSS",
236
+ v: "SSS",
289
237
  // Timezone.
290
- e: 'zz',
238
+ e: "zz",
291
239
  /**
292
240
  * Gets whether the timezone is in DST currently.
293
241
  *
@@ -296,11 +244,11 @@ const formatMap = {
296
244
  * @return Formatted date.
297
245
  */
298
246
  I(momentDate) {
299
- return momentDate.isDST() ? '1' : '0';
247
+ return momentDate.isDST() ? "1" : "0";
300
248
  },
301
- O: 'ZZ',
302
- P: 'Z',
303
- T: 'z',
249
+ O: "ZZ",
250
+ P: "Z",
251
+ T: "z",
304
252
  /**
305
253
  * Gets the timezone offset in seconds.
306
254
  *
@@ -309,14 +257,13 @@ const formatMap = {
309
257
  * @return Formatted date.
310
258
  */
311
259
  Z(momentDate) {
312
- // Timezone offset in seconds.
313
- const offset = momentDate.format('Z');
314
- const sign = offset[0] === '-' ? -1 : 1;
315
- const parts = offset.substring(1).split(':').map(n => parseInt(n, 10));
260
+ const offset = momentDate.format("Z");
261
+ const sign = offset[0] === "-" ? -1 : 1;
262
+ const parts = offset.substring(1).split(":").map((n) => parseInt(n, 10));
316
263
  return sign * (parts[0] * HOUR_IN_MINUTES + parts[1]) * MINUTE_IN_SECONDS;
317
264
  },
318
265
  // Full date/time.
319
- c: 'YYYY-MM-DDTHH:mm:ssZ',
266
+ c: "YYYY-MM-DDTHH:mm:ssZ",
320
267
  // .toISOString.
321
268
  /**
322
269
  * Formats the date as RFC2822.
@@ -326,197 +273,77 @@ const formatMap = {
326
273
  * @return Formatted date.
327
274
  */
328
275
  r(momentDate) {
329
- return momentDate.locale('en').format('ddd, DD MMM YYYY HH:mm:ss ZZ');
276
+ return momentDate.locale("en").format("ddd, DD MMM YYYY HH:mm:ss ZZ");
330
277
  },
331
- U: 'X'
278
+ U: "X"
332
279
  };
333
-
334
- /**
335
- * Formats a date. Does not alter the date's timezone.
336
- *
337
- * @param dateFormat PHP-style formatting string.
338
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
339
- * @param dateValue Date object or string,
340
- * parsable by moment.js.
341
- *
342
- * @return Formatted date.
343
- */
344
- export function format(dateFormat, dateValue = new Date()) {
280
+ function format(dateFormat, dateValue = /* @__PURE__ */ new Date()) {
345
281
  let i, char;
346
282
  const newFormat = [];
347
283
  const momentDate = momentLib(dateValue);
348
284
  for (i = 0; i < dateFormat.length; i++) {
349
285
  char = dateFormat[i];
350
- // Is this an escape?
351
- if ('\\' === char) {
352
- // Add next character, then move on.
286
+ if ("\\" === char) {
353
287
  i++;
354
- newFormat.push('[' + dateFormat[i] + ']');
288
+ newFormat.push("[" + dateFormat[i] + "]");
355
289
  continue;
356
290
  }
357
291
  if (char in formatMap) {
358
292
  const formatter = formatMap[char];
359
- if (typeof formatter !== 'string') {
360
- // If the format is a function, call it.
361
- newFormat.push('[' + formatter(momentDate) + ']');
293
+ if (typeof formatter !== "string") {
294
+ newFormat.push("[" + formatter(momentDate) + "]");
362
295
  } else {
363
- // Otherwise, add as a formatting string.
364
296
  newFormat.push(formatter);
365
297
  }
366
298
  } else {
367
- newFormat.push('[' + char + ']');
299
+ newFormat.push("[" + char + "]");
368
300
  }
369
301
  }
370
- // Join with [] between to separate characters, and replace
371
- // unneeded separators with static text.
372
- return momentDate.format(newFormat.join('[]'));
302
+ return momentDate.format(newFormat.join("[]"));
373
303
  }
374
-
375
- /**
376
- * Formats a date (like `date()` in PHP).
377
- *
378
- * @param dateFormat PHP-style formatting string.
379
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
380
- * @param dateValue Date object or string, parsable
381
- * by moment.js.
382
- * @param timezone Timezone to output result in or a
383
- * UTC offset. Defaults to timezone from
384
- * site.
385
- *
386
- * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
387
- * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
388
- *
389
- * @return {string} Formatted date in English.
390
- */
391
- export function date(dateFormat, dateValue = new Date(), timezone) {
304
+ function date(dateFormat, dateValue = /* @__PURE__ */ new Date(), timezone) {
392
305
  const dateMoment = buildMoment(dateValue, timezone);
393
306
  return format(dateFormat, dateMoment);
394
307
  }
395
-
396
- /**
397
- * Formats a date (like `date()` in PHP), in the UTC timezone.
398
- *
399
- * @param dateFormat PHP-style formatting string.
400
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
401
- * @param dateValue Date object or string,
402
- * parsable by moment.js.
403
- *
404
- * @return Formatted date in English.
405
- */
406
- export function gmdate(dateFormat, dateValue = new Date()) {
308
+ function gmdate(dateFormat, dateValue = /* @__PURE__ */ new Date()) {
407
309
  const dateMoment = momentLib(dateValue).utc();
408
310
  return format(dateFormat, dateMoment);
409
311
  }
410
-
411
- /**
412
- * Formats a date (like `wp_date()` in PHP), translating it into site's locale.
413
- *
414
- * Backward Compatibility Notice: if `timezone` is set to `true`, the function
415
- * behaves like `gmdateI18n`.
416
- *
417
- * @param dateFormat PHP-style formatting string.
418
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
419
- * @param dateValue Date object or string, parsable by
420
- * moment.js.
421
- * @param timezone Timezone to output result in or a
422
- * UTC offset. Defaults to timezone from
423
- * site. Notice: `boolean` is effectively
424
- * deprecated, but still supported for
425
- * backward compatibility reasons.
426
- *
427
- * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
428
- * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
429
- *
430
- * @return Formatted date.
431
- */
432
- export function dateI18n(dateFormat, dateValue = new Date(), timezone) {
312
+ function dateI18n(dateFormat, dateValue = /* @__PURE__ */ new Date(), timezone) {
433
313
  if (true === timezone) {
434
314
  return gmdateI18n(dateFormat, dateValue);
435
315
  }
436
316
  if (false === timezone) {
437
- timezone = undefined;
317
+ timezone = void 0;
438
318
  }
439
319
  const dateMoment = buildMoment(dateValue, timezone);
440
320
  dateMoment.locale(settings.l10n.locale);
441
321
  return format(dateFormat, dateMoment);
442
322
  }
443
-
444
- /**
445
- * Formats a date (like `wp_date()` in PHP), translating it into site's locale
446
- * and using the UTC timezone.
447
- *
448
- * @param dateFormat PHP-style formatting string.
449
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
450
- * @param dateValue Date object or string,
451
- * parsable by moment.js.
452
- *
453
- * @return Formatted date.
454
- */
455
- export function gmdateI18n(dateFormat, dateValue = new Date()) {
323
+ function gmdateI18n(dateFormat, dateValue = /* @__PURE__ */ new Date()) {
456
324
  const dateMoment = momentLib(dateValue).utc();
457
325
  dateMoment.locale(settings.l10n.locale);
458
326
  return format(dateFormat, dateMoment);
459
327
  }
460
-
461
- /**
462
- * Check whether a date is considered in the future according to the WordPress settings.
463
- *
464
- * @param dateValue Date String or Date object in the Defined WP Timezone.
465
- *
466
- * @return Is in the future.
467
- */
468
- export function isInTheFuture(dateValue) {
328
+ function isInTheFuture(dateValue) {
469
329
  const now = momentLib.tz(WP_ZONE);
470
330
  const momentObject = momentLib.tz(dateValue, WP_ZONE);
471
331
  return momentObject.isAfter(now);
472
332
  }
473
-
474
- /**
475
- * Create and return a JavaScript Date Object from a date string in the WP timezone.
476
- *
477
- * @param dateString Date formatted in the WP timezone.
478
- *
479
- * @return Date
480
- */
481
- export function getDate(dateString) {
333
+ function getDate(dateString) {
482
334
  if (!dateString) {
483
335
  return momentLib.tz(WP_ZONE).toDate();
484
336
  }
485
337
  return momentLib.tz(dateString, WP_ZONE).toDate();
486
338
  }
487
-
488
- /**
489
- * Returns a human-readable time difference between two dates, like human_time_diff() in PHP.
490
- *
491
- * @param from From date, in the WP timezone.
492
- * @param to To date, formatted in the WP timezone.
493
- *
494
- * @return Human-readable time difference.
495
- */
496
- export function humanTimeDiff(from, to) {
339
+ function humanTimeDiff(from, to) {
497
340
  const fromMoment = momentLib.tz(from, WP_ZONE);
498
341
  const toMoment = to ? momentLib.tz(to, WP_ZONE) : momentLib.tz(WP_ZONE);
499
342
  return fromMoment.from(toMoment);
500
343
  }
501
-
502
- /**
503
- * Creates a moment instance using the given timezone or, if none is provided, using global settings.
504
- *
505
- * @param dateValue Date object or string, parsable
506
- * by moment.js.
507
- * @param timezone Timezone to output result in or a
508
- * UTC offset. Defaults to timezone from
509
- * site.
510
- *
511
- * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
512
- * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
513
- *
514
- * @return A moment instance.
515
- */
516
- function buildMoment(dateValue, timezone = '') {
344
+ function buildMoment(dateValue, timezone = "") {
517
345
  const dateMoment = momentLib(dateValue);
518
346
  if (timezone && !isUTCOffset(timezone)) {
519
- // The ! isUTCOffset() check guarantees that timezone is a string.
520
347
  return dateMoment.tz(timezone);
521
348
  }
522
349
  if (timezone && isUTCOffset(timezone)) {
@@ -527,19 +354,24 @@ function buildMoment(dateValue, timezone = '') {
527
354
  }
528
355
  return dateMoment.utcOffset(+settings.timezone.offset);
529
356
  }
530
-
531
- /**
532
- * Returns whether a certain UTC offset is valid or not.
533
- *
534
- * @param offset a UTC offset.
535
- *
536
- * @return whether a certain UTC offset is valid or not.
537
- */
538
357
  function isUTCOffset(offset) {
539
- if ('number' === typeof offset) {
358
+ if ("number" === typeof offset) {
540
359
  return true;
541
360
  }
542
361
  return VALID_UTC_OFFSET.test(offset);
543
362
  }
544
363
  setupWPTimezone();
545
- //# sourceMappingURL=index.js.map
364
+ export {
365
+ __experimentalGetSettings,
366
+ date,
367
+ dateI18n,
368
+ format,
369
+ getDate,
370
+ getSettings,
371
+ gmdate,
372
+ gmdateI18n,
373
+ humanTimeDiff,
374
+ isInTheFuture,
375
+ setSettings
376
+ };
377
+ //# sourceMappingURL=index.js.map