@wordpress/date 5.29.1-next.f34ab90e9.0 → 5.30.1-next.836ecdcae.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.30.0 (2025-09-03)
6
+
7
+ ### Enhancements
8
+
9
+ - Improved TypeScript definitions ([67573](https://github.com/WordPress/gutenberg/pull/67573))
10
+
5
11
  ## 5.29.0 (2025-08-20)
6
12
 
7
13
  ## 5.28.0 (2025-08-07)
package/README.md CHANGED
@@ -28,8 +28,8 @@ _Related_
28
28
  _Parameters_
29
29
 
30
30
  - _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
31
- - _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
32
- - _timezone_ `string | number | undefined`: Timezone to output result in or a UTC offset. Defaults to timezone from site.
31
+ - _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
32
+ - _timezone_ `string`: Timezone to output result in or a UTC offset. Defaults to timezone from site.
33
33
 
34
34
  _Returns_
35
35
 
@@ -49,12 +49,12 @@ _Related_
49
49
  _Parameters_
50
50
 
51
51
  - _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
52
- - _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
53
- - _timezone_ `string | number | boolean | undefined=`: Timezone to output result in or a UTC offset. Defaults to timezone from site. Notice: `boolean` is effectively deprecated, but still supported for backward compatibility reasons.
52
+ - _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
53
+ - _timezone_ `string | number | boolean`: Timezone to output result in or a UTC offset. Defaults to timezone from site. Notice: `boolean` is effectively deprecated, but still supported for backward compatibility reasons.
54
54
 
55
55
  _Returns_
56
56
 
57
- - `string`: Formatted date.
57
+ - Formatted date.
58
58
 
59
59
  ### format
60
60
 
@@ -63,11 +63,11 @@ Formats a date. Does not alter the date's timezone.
63
63
  _Parameters_
64
64
 
65
65
  - _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
66
- - _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
66
+ - _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
67
67
 
68
68
  _Returns_
69
69
 
70
- - `string`: Formatted date.
70
+ - Formatted date.
71
71
 
72
72
  ### getDate
73
73
 
@@ -75,11 +75,11 @@ Create and return a JavaScript Date Object from a date string in the WP timezone
75
75
 
76
76
  _Parameters_
77
77
 
78
- - _dateString_ `?string`: Date formatted in the WP timezone.
78
+ - _dateString_ `string | null`: Date formatted in the WP timezone.
79
79
 
80
80
  _Returns_
81
81
 
82
- - `Date`: Date
82
+ - Date
83
83
 
84
84
  ### getSettings
85
85
 
@@ -96,11 +96,11 @@ Formats a date (like `date()` in PHP), in the UTC timezone.
96
96
  _Parameters_
97
97
 
98
98
  - _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
99
- - _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
99
+ - _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
100
100
 
101
101
  _Returns_
102
102
 
103
- - `string`: Formatted date in English.
103
+ - Formatted date in English.
104
104
 
105
105
  ### gmdateI18n
106
106
 
@@ -109,11 +109,11 @@ Formats a date (like `wp_date()` in PHP), translating it into site's locale and
109
109
  _Parameters_
110
110
 
111
111
  - _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
112
- - _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
112
+ - _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
113
113
 
114
114
  _Returns_
115
115
 
116
- - `string`: Formatted date.
116
+ - Formatted date.
117
117
 
118
118
  ### humanTimeDiff
119
119
 
@@ -121,12 +121,12 @@ Returns a human-readable time difference between two dates, like human_time_diff
121
121
 
122
122
  _Parameters_
123
123
 
124
- - _from_ `Moment | Date | string`: From date, in the WP timezone.
125
- - _to_ `Moment | Date | string | undefined`: To date, formatted in the WP timezone.
124
+ - _from_ `Moment | Date | string | number`: From date, in the WP timezone.
125
+ - _to_ `Moment | Date | string | number`: To date, formatted in the WP timezone.
126
126
 
127
127
  _Returns_
128
128
 
129
- - `string`: Human-readable time difference.
129
+ - Human-readable time difference.
130
130
 
131
131
  ### isInTheFuture
132
132
 
@@ -134,11 +134,11 @@ Check whether a date is considered in the future according to the WordPress sett
134
134
 
135
135
  _Parameters_
136
136
 
137
- - _dateValue_ `string`: Date String or Date object in the Defined WP Timezone.
137
+ - _dateValue_ `Date | string | number`: Date String or Date object in the Defined WP Timezone.
138
138
 
139
139
  _Returns_
140
140
 
141
- - `boolean`: Is in the future.
141
+ - Is in the future.
142
142
 
143
143
  ### setSettings
144
144
 
package/build/index.js CHANGED
@@ -4,6 +4,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ var _exportNames = {
8
+ setSettings: true,
9
+ getSettings: true,
10
+ __experimentalGetSettings: true,
11
+ format: true,
12
+ date: true,
13
+ gmdate: true,
14
+ dateI18n: true,
15
+ gmdateI18n: true,
16
+ isInTheFuture: true,
17
+ getDate: true,
18
+ humanTimeDiff: true
19
+ };
7
20
  exports.__experimentalGetSettings = __experimentalGetSettings;
8
21
  exports.date = date;
9
22
  exports.dateI18n = dateI18n;
@@ -19,6 +32,18 @@ var _moment = _interopRequireDefault(require("moment"));
19
32
  require("moment-timezone/moment-timezone");
20
33
  require("moment-timezone/moment-timezone-utils");
21
34
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
35
+ var _types = require("./types");
36
+ Object.keys(_types).forEach(function (key) {
37
+ if (key === "default" || key === "__esModule") return;
38
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39
+ if (key in exports && exports[key] === _types[key]) return;
40
+ Object.defineProperty(exports, key, {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _types[key];
44
+ }
45
+ });
46
+ });
22
47
  /**
23
48
  * External dependencies
24
49
  */
@@ -27,52 +52,8 @@ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
27
52
  * WordPress dependencies
28
53
  */
29
54
 
30
- /** @typedef {import('moment').Moment} Moment */
31
- /** @typedef {import('moment').LocaleSpecification} MomentLocaleSpecification */
32
-
33
- /**
34
- * @typedef MeridiemConfig
35
- * @property {string} am Lowercase AM.
36
- * @property {string} AM Uppercase AM.
37
- * @property {string} pm Lowercase PM.
38
- * @property {string} PM Uppercase PM.
39
- */
40
-
41
- /**
42
- * @typedef FormatsConfig
43
- * @property {string} time Time format.
44
- * @property {string} date Date format.
45
- * @property {string} datetime Datetime format.
46
- * @property {string} datetimeAbbreviated Abbreviated datetime format.
47
- */
48
-
49
55
  /**
50
- * @typedef TimezoneConfig
51
- * @property {string} offset Offset setting.
52
- * @property {string} offsetFormatted Offset setting with decimals formatted to minutes.
53
- * @property {string} string The timezone as a string (e.g., `'America/Los_Angeles'`).
54
- * @property {string} abbr Abbreviation for the timezone.
55
- */
56
-
57
- /* eslint-disable jsdoc/valid-types */
58
- /**
59
- * @typedef L10nSettings
60
- * @property {string} locale Moment locale.
61
- * @property {MomentLocaleSpecification['months']} months Locale months.
62
- * @property {MomentLocaleSpecification['monthsShort']} monthsShort Locale months short.
63
- * @property {MomentLocaleSpecification['weekdays']} weekdays Locale weekdays.
64
- * @property {MomentLocaleSpecification['weekdaysShort']} weekdaysShort Locale weekdays short.
65
- * @property {MeridiemConfig} meridiem Meridiem config.
66
- * @property {MomentLocaleSpecification['relativeTime']} relative Relative time config.
67
- * @property {0|1|2|3|4|5|6} startOfWeek Day that the week starts on.
68
- */
69
- /* eslint-enable jsdoc/valid-types */
70
-
71
- /**
72
- * @typedef DateSettings
73
- * @property {L10nSettings} l10n Localization settings.
74
- * @property {FormatsConfig} formats Date/time formats config.
75
- * @property {TimezoneConfig} timezone Timezone settings.
56
+ * Internal dependencies
76
57
  */
77
58
 
78
59
  const WP_ZONE = 'WP';
@@ -83,7 +64,6 @@ const VALID_UTC_OFFSET = /^[+-][0-1][0-9](:?[0-9][0-9])?$/;
83
64
 
84
65
  // Changes made here will likely need to be synced with Core in the file
85
66
  // src/wp-includes/script-loader.php in `wp_default_packages_inline_scripts()`.
86
- /** @type {DateSettings} */
87
67
  let settings = {
88
68
  l10n: {
89
69
  locale: 'en',
@@ -132,7 +112,7 @@ let settings = {
132
112
  /**
133
113
  * Adds a locale to moment, using the format supplied by `wp_localize_script()`.
134
114
  *
135
- * @param {DateSettings} dateSettings Settings, including locale data.
115
+ * @param dateSettings Settings, including locale data.
136
116
  */
137
117
  function setSettings(dateSettings) {
138
118
  settings = dateSettings;
@@ -238,31 +218,25 @@ function setupWPTimezone() {
238
218
  // Date constants.
239
219
  /**
240
220
  * Number of seconds in one minute.
241
- *
242
- * @type {number}
243
221
  */
244
222
  const MINUTE_IN_SECONDS = 60;
245
223
  /**
246
224
  * Number of minutes in one hour.
247
- *
248
- * @type {number}
249
225
  */
250
226
  const HOUR_IN_MINUTES = 60;
251
227
  /**
252
228
  * Number of seconds in one hour.
253
- *
254
- * @type {number}
255
229
  */
256
230
  const HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;
257
231
 
258
232
  /**
259
233
  * Map of PHP formats to Moment.js formats.
260
234
  *
261
- * These are used internally by {@link wp.date.format}, and are either
235
+ * These are used internally by {@link format}, and are either
262
236
  * a string representing the corresponding Moment.js format code, or a
263
237
  * function which returns the formatted string.
264
238
  *
265
- * This should only be used through {@link wp.date.format}, not
239
+ * This should only be used through {@link format}, not
266
240
  * directly.
267
241
  */
268
242
  const formatMap = {
@@ -275,9 +249,9 @@ const formatMap = {
275
249
  /**
276
250
  * Gets the ordinal suffix.
277
251
  *
278
- * @param {Moment} momentDate Moment instance.
252
+ * @param momentDate Moment instance.
279
253
  *
280
- * @return {string} Formatted date.
254
+ * @return Formatted date.
281
255
  */
282
256
  S(momentDate) {
283
257
  // Do - D.
@@ -289,9 +263,9 @@ const formatMap = {
289
263
  /**
290
264
  * Gets the day of the year (zero-indexed).
291
265
  *
292
- * @param {Moment} momentDate Moment instance.
266
+ * @param momentDate Moment instance.
293
267
  *
294
- * @return {string} Formatted date.
268
+ * @return Formatted date.
295
269
  */
296
270
  z(momentDate) {
297
271
  // DDD - 1.
@@ -307,9 +281,9 @@ const formatMap = {
307
281
  /**
308
282
  * Gets the days in the month.
309
283
  *
310
- * @param {Moment} momentDate Moment instance.
284
+ * @param momentDate Moment instance.
311
285
  *
312
- * @return {number} Formatted date.
286
+ * @return Formatted date.
313
287
  */
314
288
  t(momentDate) {
315
289
  return momentDate.daysInMonth();
@@ -318,9 +292,9 @@ const formatMap = {
318
292
  /**
319
293
  * Gets whether the current year is a leap year.
320
294
  *
321
- * @param {Moment} momentDate Moment instance.
295
+ * @param momentDate Moment instance.
322
296
  *
323
- * @return {string} Formatted date.
297
+ * @return Formatted date.
324
298
  */
325
299
  L(momentDate) {
326
300
  return momentDate.isLeapYear() ? '1' : '0';
@@ -334,9 +308,9 @@ const formatMap = {
334
308
  /**
335
309
  * Gets the current time in Swatch Internet Time (.beats).
336
310
  *
337
- * @param {Moment} momentDate Moment instance.
311
+ * @param momentDate Moment instance.
338
312
  *
339
- * @return {number} Formatted date.
313
+ * @return Formatted date.
340
314
  */
341
315
  B(momentDate) {
342
316
  const timezoned = (0, _moment.default)(momentDate).utcOffset(60);
@@ -358,9 +332,9 @@ const formatMap = {
358
332
  /**
359
333
  * Gets whether the timezone is in DST currently.
360
334
  *
361
- * @param {Moment} momentDate Moment instance.
335
+ * @param momentDate Moment instance.
362
336
  *
363
- * @return {string} Formatted date.
337
+ * @return Formatted date.
364
338
  */
365
339
  I(momentDate) {
366
340
  return momentDate.isDST() ? '1' : '0';
@@ -371,9 +345,9 @@ const formatMap = {
371
345
  /**
372
346
  * Gets the timezone offset in seconds.
373
347
  *
374
- * @param {Moment} momentDate Moment instance.
348
+ * @param momentDate Moment instance.
375
349
  *
376
- * @return {number} Formatted date.
350
+ * @return Formatted date.
377
351
  */
378
352
  Z(momentDate) {
379
353
  // Timezone offset in seconds.
@@ -388,9 +362,9 @@ const formatMap = {
388
362
  /**
389
363
  * Formats the date as RFC2822.
390
364
  *
391
- * @param {Moment} momentDate Moment instance.
365
+ * @param momentDate Moment instance.
392
366
  *
393
- * @return {string} Formatted date.
367
+ * @return Formatted date.
394
368
  */
395
369
  r(momentDate) {
396
370
  return momentDate.locale('en').format('ddd, DD MMM YYYY HH:mm:ss ZZ');
@@ -401,12 +375,12 @@ const formatMap = {
401
375
  /**
402
376
  * Formats a date. Does not alter the date's timezone.
403
377
  *
404
- * @param {string} dateFormat PHP-style formatting string.
405
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
406
- * @param {Moment | Date | string | undefined} dateValue Date object or string,
407
- * parsable by moment.js.
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,
381
+ * parsable by moment.js.
408
382
  *
409
- * @return {string} Formatted date.
383
+ * @return Formatted date.
410
384
  */
411
385
  function format(dateFormat, dateValue = new Date()) {
412
386
  let i, char;
@@ -422,7 +396,7 @@ function format(dateFormat, dateValue = new Date()) {
422
396
  continue;
423
397
  }
424
398
  if (char in formatMap) {
425
- const formatter = formatMap[(/** @type {keyof formatMap} */char)];
399
+ const formatter = formatMap[char];
426
400
  if (typeof formatter !== 'string') {
427
401
  // If the format is a function, call it.
428
402
  newFormat.push('[' + formatter(momentDate) + ']');
@@ -442,13 +416,13 @@ function format(dateFormat, dateValue = new Date()) {
442
416
  /**
443
417
  * Formats a date (like `date()` in PHP).
444
418
  *
445
- * @param {string} dateFormat PHP-style formatting string.
446
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
447
- * @param {Moment | Date | string | undefined} dateValue Date object or string, parsable
448
- * by moment.js.
449
- * @param {string | number | undefined} timezone Timezone to output result in or a
450
- * UTC offset. Defaults to timezone from
451
- * site.
419
+ * @param dateFormat PHP-style formatting string.
420
+ * See [php.net/date](https://www.php.net/manual/en/function.date.php).
421
+ * @param dateValue Date object or string, parsable
422
+ * by moment.js.
423
+ * @param timezone Timezone to output result in or a
424
+ * UTC offset. Defaults to timezone from
425
+ * site.
452
426
  *
453
427
  * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
454
428
  * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
@@ -463,12 +437,12 @@ function date(dateFormat, dateValue = new Date(), timezone) {
463
437
  /**
464
438
  * Formats a date (like `date()` in PHP), in the UTC timezone.
465
439
  *
466
- * @param {string} dateFormat PHP-style formatting string.
467
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
468
- * @param {Moment | Date | string | undefined} dateValue Date object or string,
469
- * parsable by moment.js.
440
+ * @param dateFormat PHP-style formatting string.
441
+ * See [php.net/date](https://www.php.net/manual/en/function.date.php).
442
+ * @param dateValue Date object or string,
443
+ * parsable by moment.js.
470
444
  *
471
- * @return {string} Formatted date in English.
445
+ * @return Formatted date in English.
472
446
  */
473
447
  function gmdate(dateFormat, dateValue = new Date()) {
474
448
  const dateMoment = (0, _moment.default)(dateValue).utc();
@@ -481,20 +455,20 @@ function gmdate(dateFormat, dateValue = new Date()) {
481
455
  * Backward Compatibility Notice: if `timezone` is set to `true`, the function
482
456
  * behaves like `gmdateI18n`.
483
457
  *
484
- * @param {string} dateFormat PHP-style formatting string.
485
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
486
- * @param {Moment | Date | string | undefined} dateValue Date object or string, parsable by
487
- * moment.js.
488
- * @param {string | number | boolean | undefined=} timezone Timezone to output result in or a
489
- * UTC offset. Defaults to timezone from
490
- * site. Notice: `boolean` is effectively
491
- * deprecated, but still supported for
492
- * backward compatibility reasons.
458
+ * @param dateFormat PHP-style formatting string.
459
+ * See [php.net/date](https://www.php.net/manual/en/function.date.php).
460
+ * @param dateValue Date object or string, parsable by
461
+ * moment.js.
462
+ * @param timezone Timezone to output result in or a
463
+ * UTC offset. Defaults to timezone from
464
+ * site. Notice: `boolean` is effectively
465
+ * deprecated, but still supported for
466
+ * backward compatibility reasons.
493
467
  *
494
468
  * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
495
469
  * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
496
470
  *
497
- * @return {string} Formatted date.
471
+ * @return Formatted date.
498
472
  */
499
473
  function dateI18n(dateFormat, dateValue = new Date(), timezone) {
500
474
  if (true === timezone) {
@@ -512,12 +486,12 @@ function dateI18n(dateFormat, dateValue = new Date(), timezone) {
512
486
  * Formats a date (like `wp_date()` in PHP), translating it into site's locale
513
487
  * and using the UTC timezone.
514
488
  *
515
- * @param {string} dateFormat PHP-style formatting string.
516
- * See [php.net/date](https://www.php.net/manual/en/function.date.php).
517
- * @param {Moment | Date | string | undefined} dateValue Date object or string,
518
- * parsable by moment.js.
489
+ * @param dateFormat PHP-style formatting string.
490
+ * See [php.net/date](https://www.php.net/manual/en/function.date.php).
491
+ * @param dateValue Date object or string,
492
+ * parsable by moment.js.
519
493
  *
520
- * @return {string} Formatted date.
494
+ * @return Formatted date.
521
495
  */
522
496
  function gmdateI18n(dateFormat, dateValue = new Date()) {
523
497
  const dateMoment = (0, _moment.default)(dateValue).utc();
@@ -528,9 +502,9 @@ function gmdateI18n(dateFormat, dateValue = new Date()) {
528
502
  /**
529
503
  * Check whether a date is considered in the future according to the WordPress settings.
530
504
  *
531
- * @param {string} dateValue Date String or Date object in the Defined WP Timezone.
505
+ * @param dateValue Date String or Date object in the Defined WP Timezone.
532
506
  *
533
- * @return {boolean} Is in the future.
507
+ * @return Is in the future.
534
508
  */
535
509
  function isInTheFuture(dateValue) {
536
510
  const now = _moment.default.tz(WP_ZONE);
@@ -541,9 +515,9 @@ function isInTheFuture(dateValue) {
541
515
  /**
542
516
  * Create and return a JavaScript Date Object from a date string in the WP timezone.
543
517
  *
544
- * @param {?string} dateString Date formatted in the WP timezone.
518
+ * @param dateString Date formatted in the WP timezone.
545
519
  *
546
- * @return {Date} Date
520
+ * @return Date
547
521
  */
548
522
  function getDate(dateString) {
549
523
  if (!dateString) {
@@ -555,10 +529,10 @@ function getDate(dateString) {
555
529
  /**
556
530
  * Returns a human-readable time difference between two dates, like human_time_diff() in PHP.
557
531
  *
558
- * @param {Moment | Date | string} from From date, in the WP timezone.
559
- * @param {Moment | Date | string | undefined} to To date, formatted in the WP timezone.
532
+ * @param from From date, in the WP timezone.
533
+ * @param to To date, formatted in the WP timezone.
560
534
  *
561
- * @return {string} Human-readable time difference.
535
+ * @return Human-readable time difference.
562
536
  */
563
537
  function humanTimeDiff(from, to) {
564
538
  const fromMoment = _moment.default.tz(from, WP_ZONE);
@@ -569,22 +543,22 @@ function humanTimeDiff(from, to) {
569
543
  /**
570
544
  * Creates a moment instance using the given timezone or, if none is provided, using global settings.
571
545
  *
572
- * @param {Moment | Date | string | undefined} dateValue Date object or string, parsable
573
- * by moment.js.
574
- * @param {string | number | undefined} timezone Timezone to output result in or a
575
- * UTC offset. Defaults to timezone from
576
- * site.
546
+ * @param dateValue Date object or string, parsable
547
+ * by moment.js.
548
+ * @param timezone Timezone to output result in or a
549
+ * UTC offset. Defaults to timezone from
550
+ * site.
577
551
  *
578
552
  * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
579
553
  * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
580
554
  *
581
- * @return {Moment} a moment instance.
555
+ * @return A moment instance.
582
556
  */
583
557
  function buildMoment(dateValue, timezone = '') {
584
558
  const dateMoment = (0, _moment.default)(dateValue);
585
559
  if (timezone && !isUTCOffset(timezone)) {
586
560
  // The ! isUTCOffset() check guarantees that timezone is a string.
587
- return dateMoment.tz(/** @type {string} */timezone);
561
+ return dateMoment.tz(timezone);
588
562
  }
589
563
  if (timezone && isUTCOffset(timezone)) {
590
564
  return dateMoment.utcOffset(timezone);
@@ -598,9 +572,9 @@ function buildMoment(dateValue, timezone = '') {
598
572
  /**
599
573
  * Returns whether a certain UTC offset is valid or not.
600
574
  *
601
- * @param {number|string} offset a UTC offset.
575
+ * @param offset a UTC offset.
602
576
  *
603
- * @return {boolean} whether a certain UTC offset is valid or not.
577
+ * @return whether a certain UTC offset is valid or not.
604
578
  */
605
579
  function isUTCOffset(offset) {
606
580
  if ('number' === typeof offset) {