@wordpress/date 5.42.0 → 5.43.1-next.v.202604091042.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,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.43.0 (2026-04-01)
6
+
5
7
  ## 5.42.0 (2026-03-18)
6
8
 
7
9
  ## 5.41.0 (2026-03-04)
package/build/index.cjs CHANGED
@@ -166,27 +166,36 @@ function __experimentalGetSettings() {
166
166
  });
167
167
  return getSettings();
168
168
  }
169
+ var wpZonePacked;
170
+ function ensureWPTimezone() {
171
+ if (!import_moment.default.tz.zone(WP_ZONE)) {
172
+ if (wpZonePacked) {
173
+ import_moment.default.tz.add(wpZonePacked);
174
+ } else {
175
+ setupWPTimezone();
176
+ }
177
+ }
178
+ }
169
179
  function setupWPTimezone() {
170
180
  const currentTimezone = import_moment.default.tz.zone(settings.timezone.string);
181
+ let packed;
171
182
  if (currentTimezone) {
172
- import_moment.default.tz.add(
173
- import_moment.default.tz.pack({
174
- name: WP_ZONE,
175
- abbrs: currentTimezone.abbrs,
176
- untils: currentTimezone.untils,
177
- offsets: currentTimezone.offsets
178
- })
179
- );
183
+ packed = import_moment.default.tz.pack({
184
+ name: WP_ZONE,
185
+ abbrs: currentTimezone.abbrs,
186
+ untils: currentTimezone.untils,
187
+ offsets: currentTimezone.offsets
188
+ });
180
189
  } else {
181
- import_moment.default.tz.add(
182
- import_moment.default.tz.pack({
183
- name: WP_ZONE,
184
- abbrs: [WP_ZONE],
185
- untils: [null],
186
- offsets: [-settings.timezone.offset * 60 || 0]
187
- })
188
- );
190
+ packed = import_moment.default.tz.pack({
191
+ name: WP_ZONE,
192
+ abbrs: [WP_ZONE],
193
+ untils: [null],
194
+ offsets: [-settings.timezone.offset * 60 || 0]
195
+ });
189
196
  }
197
+ wpZonePacked = packed;
198
+ import_moment.default.tz.add(packed);
190
199
  }
191
200
  var MINUTE_IN_SECONDS = 60;
192
201
  var HOUR_IN_MINUTES = 60;
@@ -370,17 +379,20 @@ function gmdateI18n(dateFormat, dateValue = /* @__PURE__ */ new Date()) {
370
379
  return format(dateFormat, dateMoment);
371
380
  }
372
381
  function isInTheFuture(dateValue) {
382
+ ensureWPTimezone();
373
383
  const now = import_moment.default.tz(WP_ZONE);
374
384
  const momentObject = import_moment.default.tz(dateValue, WP_ZONE);
375
385
  return momentObject.isAfter(now);
376
386
  }
377
387
  function getDate(dateString) {
388
+ ensureWPTimezone();
378
389
  if (!dateString) {
379
390
  return import_moment.default.tz(WP_ZONE).toDate();
380
391
  }
381
392
  return import_moment.default.tz(dateString, WP_ZONE).toDate();
382
393
  }
383
394
  function humanTimeDiff(from, to) {
395
+ ensureWPTimezone();
384
396
  const fromMoment = import_moment.default.tz(from, WP_ZONE);
385
397
  const toMoment = to ? import_moment.default.tz(to, WP_ZONE) : import_moment.default.tz(WP_ZONE);
386
398
  return fromMoment.from(toMoment);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport type { Moment } from 'moment';\nimport momentLib from 'moment';\nimport 'moment-timezone/moment-timezone.js';\nimport 'moment-timezone/moment-timezone-utils.js';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n/**\n * Internal dependencies\n */\nimport type { DateSettings } from './types';\n\nexport type * from './types';\n\nconst WP_ZONE = 'WP';\n\n// This regular expression tests positive for UTC offsets as described in ISO 8601.\n// See: https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\nconst VALID_UTC_OFFSET = /^[+-][0-1][0-9](:?[0-9][0-9])?$/;\n\n// Changes made here will likely need to be synced with Core in the file\n// src/wp-includes/script-loader.php in `wp_default_packages_inline_scripts()`.\nlet settings: DateSettings = {\n\tl10n: {\n\t\tlocale: 'en',\n\t\tmonths: [\n\t\t\t'January',\n\t\t\t'February',\n\t\t\t'March',\n\t\t\t'April',\n\t\t\t'May',\n\t\t\t'June',\n\t\t\t'July',\n\t\t\t'August',\n\t\t\t'September',\n\t\t\t'October',\n\t\t\t'November',\n\t\t\t'December',\n\t\t],\n\t\tmonthsShort: [\n\t\t\t'Jan',\n\t\t\t'Feb',\n\t\t\t'Mar',\n\t\t\t'Apr',\n\t\t\t'May',\n\t\t\t'Jun',\n\t\t\t'Jul',\n\t\t\t'Aug',\n\t\t\t'Sep',\n\t\t\t'Oct',\n\t\t\t'Nov',\n\t\t\t'Dec',\n\t\t],\n\t\tweekdays: [\n\t\t\t'Sunday',\n\t\t\t'Monday',\n\t\t\t'Tuesday',\n\t\t\t'Wednesday',\n\t\t\t'Thursday',\n\t\t\t'Friday',\n\t\t\t'Saturday',\n\t\t],\n\t\tweekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],\n\t\tmeridiem: { am: 'am', pm: 'pm', AM: 'AM', PM: 'PM' },\n\t\trelative: {\n\t\t\tfuture: '%s from now',\n\t\t\tpast: '%s ago',\n\t\t\ts: 'a few seconds',\n\t\t\tss: '%d seconds',\n\t\t\tm: 'a minute',\n\t\t\tmm: '%d minutes',\n\t\t\th: 'an hour',\n\t\t\thh: '%d hours',\n\t\t\td: 'a day',\n\t\t\tdd: '%d days',\n\t\t\tM: 'a month',\n\t\t\tMM: '%d months',\n\t\t\ty: 'a year',\n\t\t\tyy: '%d years',\n\t\t},\n\t\tstartOfWeek: 0,\n\t},\n\tformats: {\n\t\ttime: 'g:i a',\n\t\tdate: 'F j, Y',\n\t\tdatetime: 'F j, Y g:i a',\n\t\tdatetimeAbbreviated: 'M j, Y g:i a',\n\t},\n\ttimezone: { offset: 0, offsetFormatted: '0', string: '', abbr: '' },\n};\n\n/**\n * Adds a locale to moment, using the format supplied by `wp_localize_script()`.\n *\n * @param dateSettings Settings, including locale data.\n */\nexport function setSettings( dateSettings: DateSettings ) {\n\tsettings = dateSettings;\n\n\tsetupWPTimezone();\n\n\t// Does moment already have a locale with the right name?\n\tif ( momentLib.locales().includes( dateSettings.l10n.locale ) ) {\n\t\t// Is that locale misconfigured, e.g. because we are on a site running\n\t\t// WordPress < 6.0?\n\t\tif (\n\t\t\tmomentLib\n\t\t\t\t.localeData( dateSettings.l10n.locale )\n\t\t\t\t.longDateFormat( 'LTS' ) === null\n\t\t) {\n\t\t\t// Delete the misconfigured locale.\n\t\t\t// @ts-ignore Type definitions are incorrect - null is permitted.\n\t\t\tmomentLib.defineLocale( dateSettings.l10n.locale, null );\n\t\t} else {\n\t\t\t// We have a properly configured locale, so no need to create one.\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// defineLocale() will modify the current locale, so back it up.\n\tconst currentLocale = momentLib.locale();\n\n\t// Create locale.\n\tmomentLib.defineLocale( dateSettings.l10n.locale, {\n\t\t// Inherit anything missing from English. We don't load\n\t\t// moment-with-locales.js so English is all there is.\n\t\tparentLocale: 'en',\n\t\tmonths: dateSettings.l10n.months,\n\t\tmonthsShort: dateSettings.l10n.monthsShort,\n\t\tweekdays: dateSettings.l10n.weekdays,\n\t\tweekdaysShort: dateSettings.l10n.weekdaysShort,\n\t\tmeridiem( hour, minute, isLowercase ) {\n\t\t\tif ( hour < 12 ) {\n\t\t\t\treturn isLowercase\n\t\t\t\t\t? dateSettings.l10n.meridiem.am\n\t\t\t\t\t: dateSettings.l10n.meridiem.AM;\n\t\t\t}\n\t\t\treturn isLowercase\n\t\t\t\t? dateSettings.l10n.meridiem.pm\n\t\t\t\t: dateSettings.l10n.meridiem.PM;\n\t\t},\n\t\tlongDateFormat: {\n\t\t\tLT: dateSettings.formats.time,\n\t\t\tLTS: momentLib.localeData( 'en' ).longDateFormat( 'LTS' ),\n\t\t\tL: momentLib.localeData( 'en' ).longDateFormat( 'L' ),\n\t\t\tLL: dateSettings.formats.date,\n\t\t\tLLL: dateSettings.formats.datetime,\n\t\t\tLLLL: momentLib.localeData( 'en' ).longDateFormat( 'LLLL' ),\n\t\t},\n\t\t// From human_time_diff?\n\t\t// Set to `(number, withoutSuffix, key, isFuture) => {}` instead.\n\t\trelativeTime: dateSettings.l10n.relative,\n\t} );\n\n\t// Restore the locale to what it was.\n\tmomentLib.locale( currentLocale );\n}\n\n/**\n * Returns the currently defined date settings.\n *\n * @return {DateSettings} Settings, including locale data.\n */\nexport function getSettings() {\n\treturn settings;\n}\n\n/**\n * Returns the currently defined date settings.\n *\n * @deprecated\n * @return {DateSettings} Settings, including locale data.\n */\nexport function __experimentalGetSettings() {\n\tdeprecated( 'wp.date.__experimentalGetSettings', {\n\t\tsince: '6.1',\n\t\talternative: 'wp.date.getSettings',\n\t} );\n\treturn getSettings();\n}\n\nfunction setupWPTimezone() {\n\t// Get the current timezone settings from the WP timezone string.\n\tconst currentTimezone = momentLib.tz.zone( settings.timezone.string );\n\n\t// 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.\n\tif ( currentTimezone ) {\n\t\t// Create WP timezone based off settings.timezone.string. We need to include the additional data so that we\n\t\t// don't lose information about daylight savings time and other items.\n\t\t// See https://github.com/WordPress/gutenberg/pull/48083\n\t\tmomentLib.tz.add(\n\t\t\tmomentLib.tz.pack( {\n\t\t\t\tname: WP_ZONE,\n\t\t\t\tabbrs: currentTimezone.abbrs,\n\t\t\t\tuntils: currentTimezone.untils,\n\t\t\t\toffsets: currentTimezone.offsets,\n\t\t\t} )\n\t\t);\n\t} else {\n\t\t// Create WP timezone based off dateSettings.\n\t\tmomentLib.tz.add(\n\t\t\tmomentLib.tz.pack( {\n\t\t\t\tname: WP_ZONE,\n\t\t\t\tabbrs: [ WP_ZONE ],\n\t\t\t\tuntils: [ null ],\n\t\t\t\toffsets: [ -settings.timezone.offset * 60 || 0 ],\n\t\t\t} )\n\t\t);\n\t}\n}\n\n// Date constants.\n/**\n * Number of seconds in one minute.\n */\nconst MINUTE_IN_SECONDS = 60;\n/**\n * Number of minutes in one hour.\n */\nconst HOUR_IN_MINUTES = 60;\n/**\n * Number of seconds in one hour.\n */\nconst HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;\n\n/**\n * Map of PHP formats to Moment.js formats.\n *\n * These are used internally by {@link format}, and are either\n * a string representing the corresponding Moment.js format code, or a\n * function which returns the formatted string.\n *\n * This should only be used through {@link format}, not\n * directly.\n */\nconst formatMap = {\n\t// Day.\n\td: 'DD',\n\tD: 'ddd',\n\tj: 'D',\n\tl: 'dddd',\n\tN: 'E',\n\n\t/**\n\t * Gets the ordinal suffix.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tS( momentDate: Moment ) {\n\t\t// Do - D.\n\t\tconst num = momentDate.format( 'D' );\n\t\tconst withOrdinal = momentDate.format( 'Do' );\n\t\treturn withOrdinal.replace( num, '' );\n\t},\n\n\tw: 'd',\n\t/**\n\t * Gets the day of the year (zero-indexed).\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tz( momentDate: Moment ) {\n\t\t// DDD - 1.\n\t\treturn ( parseInt( momentDate.format( 'DDD' ), 10 ) - 1 ).toString();\n\t},\n\n\t// Week.\n\tW: 'W',\n\n\t// Month.\n\tF: 'MMMM',\n\tm: 'MM',\n\tM: 'MMM',\n\tn: 'M',\n\t/**\n\t * Gets the days in the month.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tt( momentDate: Moment ) {\n\t\treturn momentDate.daysInMonth();\n\t},\n\n\t// Year.\n\t/**\n\t * Gets whether the current year is a leap year.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tL( momentDate: Moment ) {\n\t\treturn momentDate.isLeapYear() ? '1' : '0';\n\t},\n\to: 'GGGG',\n\tY: 'YYYY',\n\ty: 'YY',\n\n\t// Time.\n\ta: 'a',\n\tA: 'A',\n\t/**\n\t * Gets the current time in Swatch Internet Time (.beats).\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tB( momentDate: Moment ) {\n\t\tconst timezoned = momentLib( momentDate ).utcOffset( 60 );\n\t\tconst seconds = parseInt( timezoned.format( 's' ), 10 ),\n\t\t\tminutes = parseInt( timezoned.format( 'm' ), 10 ),\n\t\t\thours = parseInt( timezoned.format( 'H' ), 10 );\n\t\treturn parseInt(\n\t\t\t(\n\t\t\t\t( seconds +\n\t\t\t\t\tminutes * MINUTE_IN_SECONDS +\n\t\t\t\t\thours * HOUR_IN_SECONDS ) /\n\t\t\t\t86.4\n\t\t\t).toString(),\n\t\t\t10\n\t\t);\n\t},\n\tg: 'h',\n\tG: 'H',\n\th: 'hh',\n\tH: 'HH',\n\ti: 'mm',\n\ts: 'ss',\n\tu: 'SSSSSS',\n\tv: 'SSS',\n\t// Timezone.\n\te: 'zz',\n\t/**\n\t * Gets whether the timezone is in DST currently.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tI( momentDate: Moment ) {\n\t\treturn momentDate.isDST() ? '1' : '0';\n\t},\n\tO: 'ZZ',\n\tP: 'Z',\n\tT: 'z',\n\t/**\n\t * Gets the timezone offset in seconds.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tZ( momentDate: Moment ) {\n\t\t// Timezone offset in seconds.\n\t\tconst offset = momentDate.format( 'Z' );\n\t\tconst sign = offset[ 0 ] === '-' ? -1 : 1;\n\t\tconst parts = offset\n\t\t\t.substring( 1 )\n\t\t\t.split( ':' )\n\t\t\t.map( ( n ) => parseInt( n, 10 ) );\n\t\treturn (\n\t\t\tsign *\n\t\t\t( parts[ 0 ] * HOUR_IN_MINUTES + parts[ 1 ] ) *\n\t\t\tMINUTE_IN_SECONDS\n\t\t);\n\t},\n\t// Full date/time.\n\tc: 'YYYY-MM-DDTHH:mm:ssZ', // .toISOString.\n\t/**\n\t * Formats the date as RFC2822.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tr( momentDate: Moment ) {\n\t\treturn momentDate\n\t\t\t.locale( 'en' )\n\t\t\t.format( 'ddd, DD MMM YYYY HH:mm:ss ZZ' );\n\t},\n\tU: 'X',\n};\n\n/**\n * Formats a date. Does not alter the date's timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date.\n */\nexport function format(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tlet i, char;\n\tconst newFormat = [];\n\tconst momentDate = momentLib( dateValue );\n\tfor ( i = 0; i < dateFormat.length; i++ ) {\n\t\tchar = dateFormat[ i ];\n\t\t// Is this an escape?\n\t\tif ( '\\\\' === char ) {\n\t\t\t// Add next character, then move on.\n\t\t\ti++;\n\t\t\tnewFormat.push( '[' + dateFormat[ i ] + ']' );\n\t\t\tcontinue;\n\t\t}\n\t\tif ( char in formatMap ) {\n\t\t\tconst formatter = formatMap[ char as keyof typeof formatMap ];\n\t\t\tif ( typeof formatter !== 'string' ) {\n\t\t\t\t// If the format is a function, call it.\n\t\t\t\tnewFormat.push( '[' + formatter( momentDate ) + ']' );\n\t\t\t} else {\n\t\t\t\t// Otherwise, add as a formatting string.\n\t\t\t\tnewFormat.push( formatter );\n\t\t\t}\n\t\t} else {\n\t\t\tnewFormat.push( '[' + char + ']' );\n\t\t}\n\t}\n\t// Join with [] between to separate characters, and replace\n\t// unneeded separators with static text.\n\treturn momentDate.format( newFormat.join( '[]' ) );\n}\n\n/**\n * Formats a date (like `date()` in PHP).\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string, parsable\n * by moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return {string} Formatted date in English.\n */\nexport function date(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date(),\n\ttimezone?: string\n) {\n\tconst dateMoment = buildMoment( dateValue, timezone );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `date()` in PHP), in the UTC timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date in English.\n */\nexport function gmdate(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tconst dateMoment = momentLib( dateValue ).utc();\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `wp_date()` in PHP), translating it into site's locale.\n *\n * Backward Compatibility Notice: if `timezone` is set to `true`, the function\n * behaves like `gmdateI18n`.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string, parsable by\n * moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site. Notice: `boolean` is effectively\n * deprecated, but still supported for\n * backward compatibility reasons.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return Formatted date.\n */\nexport function dateI18n(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date(),\n\ttimezone?: string | number | boolean\n) {\n\tif ( true === timezone ) {\n\t\treturn gmdateI18n( dateFormat, dateValue );\n\t}\n\n\tif ( false === timezone ) {\n\t\ttimezone = undefined;\n\t}\n\n\tconst dateMoment = buildMoment( dateValue, timezone );\n\tdateMoment.locale( settings.l10n.locale );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `wp_date()` in PHP), translating it into site's locale\n * and using the UTC timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date.\n */\nexport function gmdateI18n(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tconst dateMoment = momentLib( dateValue ).utc();\n\tdateMoment.locale( settings.l10n.locale );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Check whether a date is considered in the future according to the WordPress settings.\n *\n * @param dateValue Date String or Date object in the Defined WP Timezone.\n *\n * @return Is in the future.\n */\nexport function isInTheFuture( dateValue: Date | string | number ) {\n\tconst now = momentLib.tz( WP_ZONE );\n\tconst momentObject = momentLib.tz( dateValue, WP_ZONE );\n\n\treturn momentObject.isAfter( now );\n}\n\n/**\n * Create and return a JavaScript Date Object from a date string in the WP timezone.\n *\n * @param dateString Date formatted in the WP timezone.\n *\n * @return Date\n */\nexport function getDate( dateString?: string | null ) {\n\tif ( ! dateString ) {\n\t\treturn momentLib.tz( WP_ZONE ).toDate();\n\t}\n\n\treturn momentLib.tz( dateString, WP_ZONE ).toDate();\n}\n\n/**\n * Returns a human-readable time difference between two dates, like human_time_diff() in PHP.\n *\n * @param from From date, in the WP timezone.\n * @param to To date, formatted in the WP timezone.\n *\n * @return Human-readable time difference.\n */\nexport function humanTimeDiff(\n\tfrom: Moment | Date | string | number,\n\tto?: Moment | Date | string | number\n) {\n\tconst fromMoment = momentLib.tz( from, WP_ZONE );\n\tconst toMoment = to ? momentLib.tz( to, WP_ZONE ) : momentLib.tz( WP_ZONE );\n\treturn fromMoment.from( toMoment );\n}\n\n/**\n * Creates a moment instance using the given timezone or, if none is provided, using global settings.\n *\n * @param dateValue Date object or string, parsable\n * by moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return A moment instance.\n */\nfunction buildMoment(\n\tdateValue?: Moment | Date | string | number,\n\ttimezone: string | number = ''\n) {\n\tconst dateMoment = momentLib( dateValue );\n\n\tif ( timezone !== '' ) {\n\t\treturn isUTCOffset( timezone )\n\t\t\t? dateMoment.utcOffset( timezone )\n\t\t\t: // A false isUTCOffset() guarantees that timezone is a string.\n\t\t\t dateMoment.tz( timezone as string );\n\t}\n\n\tif ( settings.timezone.string ) {\n\t\treturn dateMoment.tz( settings.timezone.string );\n\t}\n\n\treturn dateMoment.utcOffset( +settings.timezone.offset );\n}\n\n/**\n * Returns whether a certain UTC offset is valid or not.\n *\n * @param offset a UTC offset.\n *\n * @return whether a certain UTC offset is valid or not.\n */\nfunction isUTCOffset( offset: number | string ) {\n\tif ( 'number' === typeof offset ) {\n\t\treturn true;\n\t}\n\n\treturn VALID_UTC_OFFSET.test( offset );\n}\n\nsetupWPTimezone();\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAsB;AACtB,6BAAO;AACP,mCAAO;AAKP,wBAAuB;AAQvB,IAAM,UAAU;AAIhB,IAAM,mBAAmB;AAIzB,IAAI,WAAyB;AAAA,EAC5B,MAAM;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA,aAAa;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA,UAAU;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;A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I;AAClC;AASO,SAAS,QAAS,YAA6B;AACrD,MAAK,CAAE,YAAa;AACnB,WAAO,cAAAA,QAAU,GAAI,OAAQ,EAAE,OAAO;AAAA,EACvC;AAEA,SAAO,cAAAA,QAAU,GAAI,YAAY,OAAQ,EAAE,OAAO;AACnD;AAUO,SAAS,cACf,MACA,IACC;AACD,QAAM,aAAa,cAAAA,QAAU,GAAI,MAAM,OAAQ;AAC/C,QAAM,WAAW,KAAK,cAAAA,QAAU,GAAI,IAAI,OAAQ,IAAI,cAAAA,QAAU,GAAI,OAAQ;AAC1E,SAAO,WAAW,KAAM,QAAS;AAClC;AAgBA,SAAS,YACR,WACA,WAA4B,IAC3B;AACD,QAAM,iBAAa,cAAAA,SAAW,SAAU;AAExC,MAAK,aAAa,IAAK;AACtB,WAAO,YAAa,QAAS,IAC1B,WAAW,UAAW,QAAS;AAAA;AAAA,MAE/B,WAAW,GAAI,QAAmB;AAAA;AAAA,EACtC;AAEA,MAAK,SAAS,SAAS,QAAS;AAC/B,WAAO,WAAW,GAAI,SAAS,SAAS,MAAO;AAAA,EAChD;AAEA,SAAO,WAAW,UAAW,CAAC,SAAS,SAAS,MAAO;AACxD;AASA,SAAS,YAAa,QAA0B;AAC/C,MAAK,aAAa,OAAO,QAAS;AACjC,WAAO;AAAA,EACR;AAEA,SAAO,iBAAiB,KAAM,MAAO;AACtC;AAEA,gBAAgB;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { Moment } from 'moment';\nimport momentLib from 'moment';\nimport 'moment-timezone/moment-timezone.js';\nimport 'moment-timezone/moment-timezone-utils.js';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n/**\n * Internal dependencies\n */\nimport type { DateSettings } from './types';\n\nexport type * from './types';\n\nconst WP_ZONE = 'WP';\n\n// This regular expression tests positive for UTC offsets as described in ISO 8601.\n// See: https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\nconst VALID_UTC_OFFSET = /^[+-][0-1][0-9](:?[0-9][0-9])?$/;\n\n// Changes made here will likely need to be synced with Core in the file\n// src/wp-includes/script-loader.php in `wp_default_packages_inline_scripts()`.\nlet settings: DateSettings = {\n\tl10n: {\n\t\tlocale: 'en',\n\t\tmonths: [\n\t\t\t'January',\n\t\t\t'February',\n\t\t\t'March',\n\t\t\t'April',\n\t\t\t'May',\n\t\t\t'June',\n\t\t\t'July',\n\t\t\t'August',\n\t\t\t'September',\n\t\t\t'October',\n\t\t\t'November',\n\t\t\t'December',\n\t\t],\n\t\tmonthsShort: [\n\t\t\t'Jan',\n\t\t\t'Feb',\n\t\t\t'Mar',\n\t\t\t'Apr',\n\t\t\t'May',\n\t\t\t'Jun',\n\t\t\t'Jul',\n\t\t\t'Aug',\n\t\t\t'Sep',\n\t\t\t'Oct',\n\t\t\t'Nov',\n\t\t\t'Dec',\n\t\t],\n\t\tweekdays: [\n\t\t\t'Sunday',\n\t\t\t'Monday',\n\t\t\t'Tuesday',\n\t\t\t'Wednesday',\n\t\t\t'Thursday',\n\t\t\t'Friday',\n\t\t\t'Saturday',\n\t\t],\n\t\tweekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],\n\t\tmeridiem: { am: 'am', pm: 'pm', AM: 'AM', PM: 'PM' },\n\t\trelative: {\n\t\t\tfuture: '%s from now',\n\t\t\tpast: '%s ago',\n\t\t\ts: 'a few seconds',\n\t\t\tss: '%d seconds',\n\t\t\tm: 'a minute',\n\t\t\tmm: '%d minutes',\n\t\t\th: 'an hour',\n\t\t\thh: '%d hours',\n\t\t\td: 'a day',\n\t\t\tdd: '%d days',\n\t\t\tM: 'a month',\n\t\t\tMM: '%d months',\n\t\t\ty: 'a year',\n\t\t\tyy: '%d years',\n\t\t},\n\t\tstartOfWeek: 0,\n\t},\n\tformats: {\n\t\ttime: 'g:i a',\n\t\tdate: 'F j, Y',\n\t\tdatetime: 'F j, Y g:i a',\n\t\tdatetimeAbbreviated: 'M j, Y g:i a',\n\t},\n\ttimezone: { offset: 0, offsetFormatted: '0', string: '', abbr: '' },\n};\n\n/**\n * Adds a locale to moment, using the format supplied by `wp_localize_script()`.\n *\n * @param dateSettings Settings, including locale data.\n */\nexport function setSettings( dateSettings: DateSettings ) {\n\tsettings = dateSettings;\n\n\tsetupWPTimezone();\n\n\t// Does moment already have a locale with the right name?\n\tif ( momentLib.locales().includes( dateSettings.l10n.locale ) ) {\n\t\t// Is that locale misconfigured, e.g. because we are on a site running\n\t\t// WordPress < 6.0?\n\t\tif (\n\t\t\tmomentLib\n\t\t\t\t.localeData( dateSettings.l10n.locale )\n\t\t\t\t.longDateFormat( 'LTS' ) === null\n\t\t) {\n\t\t\t// Delete the misconfigured locale.\n\t\t\t// @ts-ignore Type definitions are incorrect - null is permitted.\n\t\t\tmomentLib.defineLocale( dateSettings.l10n.locale, null );\n\t\t} else {\n\t\t\t// We have a properly configured locale, so no need to create one.\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// defineLocale() will modify the current locale, so back it up.\n\tconst currentLocale = momentLib.locale();\n\n\t// Create locale.\n\tmomentLib.defineLocale( dateSettings.l10n.locale, {\n\t\t// Inherit anything missing from English. We don't load\n\t\t// moment-with-locales.js so English is all there is.\n\t\tparentLocale: 'en',\n\t\tmonths: dateSettings.l10n.months,\n\t\tmonthsShort: dateSettings.l10n.monthsShort,\n\t\tweekdays: dateSettings.l10n.weekdays,\n\t\tweekdaysShort: dateSettings.l10n.weekdaysShort,\n\t\tmeridiem( hour, minute, isLowercase ) {\n\t\t\tif ( hour < 12 ) {\n\t\t\t\treturn isLowercase\n\t\t\t\t\t? dateSettings.l10n.meridiem.am\n\t\t\t\t\t: dateSettings.l10n.meridiem.AM;\n\t\t\t}\n\t\t\treturn isLowercase\n\t\t\t\t? dateSettings.l10n.meridiem.pm\n\t\t\t\t: dateSettings.l10n.meridiem.PM;\n\t\t},\n\t\tlongDateFormat: {\n\t\t\tLT: dateSettings.formats.time,\n\t\t\tLTS: momentLib.localeData( 'en' ).longDateFormat( 'LTS' ),\n\t\t\tL: momentLib.localeData( 'en' ).longDateFormat( 'L' ),\n\t\t\tLL: dateSettings.formats.date,\n\t\t\tLLL: dateSettings.formats.datetime,\n\t\t\tLLLL: momentLib.localeData( 'en' ).longDateFormat( 'LLLL' ),\n\t\t},\n\t\t// From human_time_diff?\n\t\t// Set to `(number, withoutSuffix, key, isFuture) => {}` instead.\n\t\trelativeTime: dateSettings.l10n.relative,\n\t} );\n\n\t// Restore the locale to what it was.\n\tmomentLib.locale( currentLocale );\n}\n\n/**\n * Returns the currently defined date settings.\n *\n * @return {DateSettings} Settings, including locale data.\n */\nexport function getSettings() {\n\treturn settings;\n}\n\n/**\n * Returns the currently defined date settings.\n *\n * @deprecated\n * @return {DateSettings} Settings, including locale data.\n */\nexport function __experimentalGetSettings() {\n\tdeprecated( 'wp.date.__experimentalGetSettings', {\n\t\tsince: '6.1',\n\t\talternative: 'wp.date.getSettings',\n\t} );\n\treturn getSettings();\n}\n\n// Cached packed zone string, used to re-add the WP zone without requiring\n// moment-timezone-utils (which provides .pack()) after a third-party plugin\n// reloads moment-timezone and destroys both the zone and the utils.\nlet wpZonePacked: string | undefined;\n\n/**\n * Ensures the custom WP timezone zone exists in moment-timezone's registry.\n *\n * Third-party plugins (e.g. WooCommerce) may load their own copy of\n * moment-timezone, which reinitializes the internal zone storage and\n * destroys the custom 'WP' zone. This function checks for the zone's\n * existence and re-creates it if necessary.\n */\nfunction ensureWPTimezone() {\n\tif ( ! momentLib.tz.zone( WP_ZONE ) ) {\n\t\tif ( wpZonePacked ) {\n\t\t\tmomentLib.tz.add( wpZonePacked );\n\t\t} else {\n\t\t\tsetupWPTimezone();\n\t\t}\n\t}\n}\n\nfunction setupWPTimezone() {\n\t// Get the current timezone settings from the WP timezone string.\n\tconst currentTimezone = momentLib.tz.zone( settings.timezone.string );\n\n\tlet packed;\n\t// 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.\n\tif ( currentTimezone ) {\n\t\t// Create WP timezone based off settings.timezone.string. We need to include the additional data so that we\n\t\t// don't lose information about daylight savings time and other items.\n\t\t// See https://github.com/WordPress/gutenberg/pull/48083\n\t\tpacked = momentLib.tz.pack( {\n\t\t\tname: WP_ZONE,\n\t\t\tabbrs: currentTimezone.abbrs,\n\t\t\tuntils: currentTimezone.untils,\n\t\t\toffsets: currentTimezone.offsets,\n\t\t} );\n\t} else {\n\t\t// Create WP timezone based off dateSettings.\n\t\tpacked = momentLib.tz.pack( {\n\t\t\tname: WP_ZONE,\n\t\t\tabbrs: [ WP_ZONE ],\n\t\t\tuntils: [ null ],\n\t\t\toffsets: [ -settings.timezone.offset * 60 || 0 ],\n\t\t} );\n\t}\n\n\twpZonePacked = packed;\n\tmomentLib.tz.add( packed );\n}\n\n// Date constants.\n/**\n * Number of seconds in one minute.\n */\nconst MINUTE_IN_SECONDS = 60;\n/**\n * Number of minutes in one hour.\n */\nconst HOUR_IN_MINUTES = 60;\n/**\n * Number of seconds in one hour.\n */\nconst HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;\n\n/**\n * Map of PHP formats to Moment.js formats.\n *\n * These are used internally by {@link format}, and are either\n * a string representing the corresponding Moment.js format code, or a\n * function which returns the formatted string.\n *\n * This should only be used through {@link format}, not\n * directly.\n */\nconst formatMap = {\n\t// Day.\n\td: 'DD',\n\tD: 'ddd',\n\tj: 'D',\n\tl: 'dddd',\n\tN: 'E',\n\n\t/**\n\t * Gets the ordinal suffix.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tS( momentDate: Moment ) {\n\t\t// Do - D.\n\t\tconst num = momentDate.format( 'D' );\n\t\tconst withOrdinal = momentDate.format( 'Do' );\n\t\treturn withOrdinal.replace( num, '' );\n\t},\n\n\tw: 'd',\n\t/**\n\t * Gets the day of the year (zero-indexed).\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tz( momentDate: Moment ) {\n\t\t// DDD - 1.\n\t\treturn ( parseInt( momentDate.format( 'DDD' ), 10 ) - 1 ).toString();\n\t},\n\n\t// Week.\n\tW: 'W',\n\n\t// Month.\n\tF: 'MMMM',\n\tm: 'MM',\n\tM: 'MMM',\n\tn: 'M',\n\t/**\n\t * Gets the days in the month.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tt( momentDate: Moment ) {\n\t\treturn momentDate.daysInMonth();\n\t},\n\n\t// Year.\n\t/**\n\t * Gets whether the current year is a leap year.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tL( momentDate: Moment ) {\n\t\treturn momentDate.isLeapYear() ? '1' : '0';\n\t},\n\to: 'GGGG',\n\tY: 'YYYY',\n\ty: 'YY',\n\n\t// Time.\n\ta: 'a',\n\tA: 'A',\n\t/**\n\t * Gets the current time in Swatch Internet Time (.beats).\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tB( momentDate: Moment ) {\n\t\tconst timezoned = momentLib( momentDate ).utcOffset( 60 );\n\t\tconst seconds = parseInt( timezoned.format( 's' ), 10 ),\n\t\t\tminutes = parseInt( timezoned.format( 'm' ), 10 ),\n\t\t\thours = parseInt( timezoned.format( 'H' ), 10 );\n\t\treturn parseInt(\n\t\t\t(\n\t\t\t\t( seconds +\n\t\t\t\t\tminutes * MINUTE_IN_SECONDS +\n\t\t\t\t\thours * HOUR_IN_SECONDS ) /\n\t\t\t\t86.4\n\t\t\t).toString(),\n\t\t\t10\n\t\t);\n\t},\n\tg: 'h',\n\tG: 'H',\n\th: 'hh',\n\tH: 'HH',\n\ti: 'mm',\n\ts: 'ss',\n\tu: 'SSSSSS',\n\tv: 'SSS',\n\t// Timezone.\n\te: 'zz',\n\t/**\n\t * Gets whether the timezone is in DST currently.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tI( momentDate: Moment ) {\n\t\treturn momentDate.isDST() ? '1' : '0';\n\t},\n\tO: 'ZZ',\n\tP: 'Z',\n\tT: 'z',\n\t/**\n\t * Gets the timezone offset in seconds.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tZ( momentDate: Moment ) {\n\t\t// Timezone offset in seconds.\n\t\tconst offset = momentDate.format( 'Z' );\n\t\tconst sign = offset[ 0 ] === '-' ? -1 : 1;\n\t\tconst parts = offset\n\t\t\t.substring( 1 )\n\t\t\t.split( ':' )\n\t\t\t.map( ( n ) => parseInt( n, 10 ) );\n\t\treturn (\n\t\t\tsign *\n\t\t\t( parts[ 0 ] * HOUR_IN_MINUTES + parts[ 1 ] ) *\n\t\t\tMINUTE_IN_SECONDS\n\t\t);\n\t},\n\t// Full date/time.\n\tc: 'YYYY-MM-DDTHH:mm:ssZ', // .toISOString.\n\t/**\n\t * Formats the date as RFC2822.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tr( momentDate: Moment ) {\n\t\treturn momentDate\n\t\t\t.locale( 'en' )\n\t\t\t.format( 'ddd, DD MMM YYYY HH:mm:ss ZZ' );\n\t},\n\tU: 'X',\n};\n\n/**\n * Formats a date. Does not alter the date's timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date.\n */\nexport function format(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tlet i, char;\n\tconst newFormat = [];\n\tconst momentDate = momentLib( dateValue );\n\tfor ( i = 0; i < dateFormat.length; i++ ) {\n\t\tchar = dateFormat[ i ];\n\t\t// Is this an escape?\n\t\tif ( '\\\\' === char ) {\n\t\t\t// Add next character, then move on.\n\t\t\ti++;\n\t\t\tnewFormat.push( '[' + dateFormat[ i ] + ']' );\n\t\t\tcontinue;\n\t\t}\n\t\tif ( char in formatMap ) {\n\t\t\tconst formatter = formatMap[ char as keyof typeof formatMap ];\n\t\t\tif ( typeof formatter !== 'string' ) {\n\t\t\t\t// If the format is a function, call it.\n\t\t\t\tnewFormat.push( '[' + formatter( momentDate ) + ']' );\n\t\t\t} else {\n\t\t\t\t// Otherwise, add as a formatting string.\n\t\t\t\tnewFormat.push( formatter );\n\t\t\t}\n\t\t} else {\n\t\t\tnewFormat.push( '[' + char + ']' );\n\t\t}\n\t}\n\t// Join with [] between to separate characters, and replace\n\t// unneeded separators with static text.\n\treturn momentDate.format( newFormat.join( '[]' ) );\n}\n\n/**\n * Formats a date (like `date()` in PHP).\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string, parsable\n * by moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return {string} Formatted date in English.\n */\nexport function date(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date(),\n\ttimezone?: string\n) {\n\tconst dateMoment = buildMoment( dateValue, timezone );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `date()` in PHP), in the UTC timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date in English.\n */\nexport function gmdate(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tconst dateMoment = momentLib( dateValue ).utc();\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `wp_date()` in PHP), translating it into site's locale.\n *\n * Backward Compatibility Notice: if `timezone` is set to `true`, the function\n * behaves like `gmdateI18n`.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string, parsable by\n * moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site. Notice: `boolean` is effectively\n * deprecated, but still supported for\n * backward compatibility reasons.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return Formatted date.\n */\nexport function dateI18n(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date(),\n\ttimezone?: string | number | boolean\n) {\n\tif ( true === timezone ) {\n\t\treturn gmdateI18n( dateFormat, dateValue );\n\t}\n\n\tif ( false === timezone ) {\n\t\ttimezone = undefined;\n\t}\n\n\tconst dateMoment = buildMoment( dateValue, timezone );\n\tdateMoment.locale( settings.l10n.locale );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `wp_date()` in PHP), translating it into site's locale\n * and using the UTC timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date.\n */\nexport function gmdateI18n(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tconst dateMoment = momentLib( dateValue ).utc();\n\tdateMoment.locale( settings.l10n.locale );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Check whether a date is considered in the future according to the WordPress settings.\n *\n * @param dateValue Date String or Date object in the Defined WP Timezone.\n *\n * @return Is in the future.\n */\nexport function isInTheFuture( dateValue: Date | string | number ) {\n\tensureWPTimezone();\n\tconst now = momentLib.tz( WP_ZONE );\n\tconst momentObject = momentLib.tz( dateValue, WP_ZONE );\n\n\treturn momentObject.isAfter( now );\n}\n\n/**\n * Create and return a JavaScript Date Object from a date string in the WP timezone.\n *\n * @param dateString Date formatted in the WP timezone.\n *\n * @return Date\n */\nexport function getDate( dateString?: string | null ) {\n\tensureWPTimezone();\n\tif ( ! dateString ) {\n\t\treturn momentLib.tz( WP_ZONE ).toDate();\n\t}\n\n\treturn momentLib.tz( dateString, WP_ZONE ).toDate();\n}\n\n/**\n * Returns a human-readable time difference between two dates, like human_time_diff() in PHP.\n *\n * @param from From date, in the WP timezone.\n * @param to To date, formatted in the WP timezone.\n *\n * @return Human-readable time difference.\n */\nexport function humanTimeDiff(\n\tfrom: Moment | Date | string | number,\n\tto?: Moment | Date | string | number\n) {\n\tensureWPTimezone();\n\tconst fromMoment = momentLib.tz( from, WP_ZONE );\n\tconst toMoment = to ? momentLib.tz( to, WP_ZONE ) : momentLib.tz( WP_ZONE );\n\treturn fromMoment.from( toMoment );\n}\n\n/**\n * Creates a moment instance using the given timezone or, if none is provided, using global settings.\n *\n * @param dateValue Date object or string, parsable\n * by moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return A moment instance.\n */\nfunction buildMoment(\n\tdateValue?: Moment | Date | string | number,\n\ttimezone: string | number = ''\n) {\n\tconst dateMoment = momentLib( dateValue );\n\n\tif ( timezone !== '' ) {\n\t\treturn isUTCOffset( timezone )\n\t\t\t? dateMoment.utcOffset( timezone )\n\t\t\t: // A false isUTCOffset() guarantees that timezone is a string.\n\t\t\t dateMoment.tz( timezone as string );\n\t}\n\n\tif ( settings.timezone.string ) {\n\t\treturn dateMoment.tz( settings.timezone.string );\n\t}\n\n\treturn dateMoment.utcOffset( +settings.timezone.offset );\n}\n\n/**\n * Returns whether a certain UTC offset is valid or not.\n *\n * @param offset a UTC offset.\n *\n * @return whether a certain UTC offset is valid or not.\n */\nfunction isUTCOffset( offset: number | string ) {\n\tif ( 'number' === typeof offset ) {\n\t\treturn true;\n\t}\n\n\treturn VALID_UTC_OFFSET.test( offset );\n}\n\nsetupWPTimezone();\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;A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AAI,OAAQ;AAC1E,SAAO,WAAW,KAAM,QAAS;AAClC;AAgBA,SAAS,YACR,WACA,WAA4B,IAC3B;AACD,QAAM,iBAAa,cAAAA,SAAW,SAAU;AAExC,MAAK,aAAa,IAAK;AACtB,WAAO,YAAa,QAAS,IAC1B,WAAW,UAAW,QAAS;AAAA;AAAA,MAE/B,WAAW,GAAI,QAAmB;AAAA;AAAA,EACtC;AAEA,MAAK,SAAS,SAAS,QAAS;AAC/B,WAAO,WAAW,GAAI,SAAS,SAAS,MAAO;AAAA,EAChD;AAEA,SAAO,WAAW,UAAW,CAAC,SAAS,SAAS,MAAO;AACxD;AASA,SAAS,YAAa,QAA0B;AAC/C,MAAK,aAAa,OAAO,QAAS;AACjC,WAAO;AAAA,EACR;AAEA,SAAO,iBAAiB,KAAM,MAAO;AACtC;AAEA,gBAAgB;",
6
6
  "names": ["momentLib", "deprecated"]
7
7
  }
@@ -122,27 +122,36 @@ function __experimentalGetSettings() {
122
122
  });
123
123
  return getSettings();
124
124
  }
125
+ var wpZonePacked;
126
+ function ensureWPTimezone() {
127
+ if (!momentLib.tz.zone(WP_ZONE)) {
128
+ if (wpZonePacked) {
129
+ momentLib.tz.add(wpZonePacked);
130
+ } else {
131
+ setupWPTimezone();
132
+ }
133
+ }
134
+ }
125
135
  function setupWPTimezone() {
126
136
  const currentTimezone = momentLib.tz.zone(settings.timezone.string);
137
+ let packed;
127
138
  if (currentTimezone) {
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
- );
139
+ packed = momentLib.tz.pack({
140
+ name: WP_ZONE,
141
+ abbrs: currentTimezone.abbrs,
142
+ untils: currentTimezone.untils,
143
+ offsets: currentTimezone.offsets
144
+ });
136
145
  } else {
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
- );
146
+ packed = momentLib.tz.pack({
147
+ name: WP_ZONE,
148
+ abbrs: [WP_ZONE],
149
+ untils: [null],
150
+ offsets: [-settings.timezone.offset * 60 || 0]
151
+ });
145
152
  }
153
+ wpZonePacked = packed;
154
+ momentLib.tz.add(packed);
146
155
  }
147
156
  var MINUTE_IN_SECONDS = 60;
148
157
  var HOUR_IN_MINUTES = 60;
@@ -326,17 +335,20 @@ function gmdateI18n(dateFormat, dateValue = /* @__PURE__ */ new Date()) {
326
335
  return format(dateFormat, dateMoment);
327
336
  }
328
337
  function isInTheFuture(dateValue) {
338
+ ensureWPTimezone();
329
339
  const now = momentLib.tz(WP_ZONE);
330
340
  const momentObject = momentLib.tz(dateValue, WP_ZONE);
331
341
  return momentObject.isAfter(now);
332
342
  }
333
343
  function getDate(dateString) {
344
+ ensureWPTimezone();
334
345
  if (!dateString) {
335
346
  return momentLib.tz(WP_ZONE).toDate();
336
347
  }
337
348
  return momentLib.tz(dateString, WP_ZONE).toDate();
338
349
  }
339
350
  function humanTimeDiff(from, to) {
351
+ ensureWPTimezone();
340
352
  const fromMoment = momentLib.tz(from, WP_ZONE);
341
353
  const toMoment = to ? momentLib.tz(to, WP_ZONE) : momentLib.tz(WP_ZONE);
342
354
  return fromMoment.from(toMoment);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport type { Moment } from 'moment';\nimport momentLib from 'moment';\nimport 'moment-timezone/moment-timezone.js';\nimport 'moment-timezone/moment-timezone-utils.js';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n/**\n * Internal dependencies\n */\nimport type { DateSettings } from './types';\n\nexport type * from './types';\n\nconst WP_ZONE = 'WP';\n\n// This regular expression tests positive for UTC offsets as described in ISO 8601.\n// See: https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\nconst VALID_UTC_OFFSET = /^[+-][0-1][0-9](:?[0-9][0-9])?$/;\n\n// Changes made here will likely need to be synced with Core in the file\n// src/wp-includes/script-loader.php in `wp_default_packages_inline_scripts()`.\nlet settings: DateSettings = {\n\tl10n: {\n\t\tlocale: 'en',\n\t\tmonths: [\n\t\t\t'January',\n\t\t\t'February',\n\t\t\t'March',\n\t\t\t'April',\n\t\t\t'May',\n\t\t\t'June',\n\t\t\t'July',\n\t\t\t'August',\n\t\t\t'September',\n\t\t\t'October',\n\t\t\t'November',\n\t\t\t'December',\n\t\t],\n\t\tmonthsShort: [\n\t\t\t'Jan',\n\t\t\t'Feb',\n\t\t\t'Mar',\n\t\t\t'Apr',\n\t\t\t'May',\n\t\t\t'Jun',\n\t\t\t'Jul',\n\t\t\t'Aug',\n\t\t\t'Sep',\n\t\t\t'Oct',\n\t\t\t'Nov',\n\t\t\t'Dec',\n\t\t],\n\t\tweekdays: [\n\t\t\t'Sunday',\n\t\t\t'Monday',\n\t\t\t'Tuesday',\n\t\t\t'Wednesday',\n\t\t\t'Thursday',\n\t\t\t'Friday',\n\t\t\t'Saturday',\n\t\t],\n\t\tweekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],\n\t\tmeridiem: { am: 'am', pm: 'pm', AM: 'AM', PM: 'PM' },\n\t\trelative: {\n\t\t\tfuture: '%s from now',\n\t\t\tpast: '%s ago',\n\t\t\ts: 'a few seconds',\n\t\t\tss: '%d seconds',\n\t\t\tm: 'a minute',\n\t\t\tmm: '%d minutes',\n\t\t\th: 'an hour',\n\t\t\thh: '%d hours',\n\t\t\td: 'a day',\n\t\t\tdd: '%d days',\n\t\t\tM: 'a month',\n\t\t\tMM: '%d months',\n\t\t\ty: 'a year',\n\t\t\tyy: '%d years',\n\t\t},\n\t\tstartOfWeek: 0,\n\t},\n\tformats: {\n\t\ttime: 'g:i a',\n\t\tdate: 'F j, Y',\n\t\tdatetime: 'F j, Y g:i a',\n\t\tdatetimeAbbreviated: 'M j, Y g:i a',\n\t},\n\ttimezone: { offset: 0, offsetFormatted: '0', string: '', abbr: '' },\n};\n\n/**\n * Adds a locale to moment, using the format supplied by `wp_localize_script()`.\n *\n * @param dateSettings Settings, including locale data.\n */\nexport function setSettings( dateSettings: DateSettings ) {\n\tsettings = dateSettings;\n\n\tsetupWPTimezone();\n\n\t// Does moment already have a locale with the right name?\n\tif ( momentLib.locales().includes( dateSettings.l10n.locale ) ) {\n\t\t// Is that locale misconfigured, e.g. because we are on a site running\n\t\t// WordPress < 6.0?\n\t\tif (\n\t\t\tmomentLib\n\t\t\t\t.localeData( dateSettings.l10n.locale )\n\t\t\t\t.longDateFormat( 'LTS' ) === null\n\t\t) {\n\t\t\t// Delete the misconfigured locale.\n\t\t\t// @ts-ignore Type definitions are incorrect - null is permitted.\n\t\t\tmomentLib.defineLocale( dateSettings.l10n.locale, null );\n\t\t} else {\n\t\t\t// We have a properly configured locale, so no need to create one.\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// defineLocale() will modify the current locale, so back it up.\n\tconst currentLocale = momentLib.locale();\n\n\t// Create locale.\n\tmomentLib.defineLocale( dateSettings.l10n.locale, {\n\t\t// Inherit anything missing from English. We don't load\n\t\t// moment-with-locales.js so English is all there is.\n\t\tparentLocale: 'en',\n\t\tmonths: dateSettings.l10n.months,\n\t\tmonthsShort: dateSettings.l10n.monthsShort,\n\t\tweekdays: dateSettings.l10n.weekdays,\n\t\tweekdaysShort: dateSettings.l10n.weekdaysShort,\n\t\tmeridiem( hour, minute, isLowercase ) {\n\t\t\tif ( hour < 12 ) {\n\t\t\t\treturn isLowercase\n\t\t\t\t\t? dateSettings.l10n.meridiem.am\n\t\t\t\t\t: dateSettings.l10n.meridiem.AM;\n\t\t\t}\n\t\t\treturn isLowercase\n\t\t\t\t? dateSettings.l10n.meridiem.pm\n\t\t\t\t: dateSettings.l10n.meridiem.PM;\n\t\t},\n\t\tlongDateFormat: {\n\t\t\tLT: dateSettings.formats.time,\n\t\t\tLTS: momentLib.localeData( 'en' ).longDateFormat( 'LTS' ),\n\t\t\tL: momentLib.localeData( 'en' ).longDateFormat( 'L' ),\n\t\t\tLL: dateSettings.formats.date,\n\t\t\tLLL: dateSettings.formats.datetime,\n\t\t\tLLLL: momentLib.localeData( 'en' ).longDateFormat( 'LLLL' ),\n\t\t},\n\t\t// From human_time_diff?\n\t\t// Set to `(number, withoutSuffix, key, isFuture) => {}` instead.\n\t\trelativeTime: dateSettings.l10n.relative,\n\t} );\n\n\t// Restore the locale to what it was.\n\tmomentLib.locale( currentLocale );\n}\n\n/**\n * Returns the currently defined date settings.\n *\n * @return {DateSettings} Settings, including locale data.\n */\nexport function getSettings() {\n\treturn settings;\n}\n\n/**\n * Returns the currently defined date settings.\n *\n * @deprecated\n * @return {DateSettings} Settings, including locale data.\n */\nexport function __experimentalGetSettings() {\n\tdeprecated( 'wp.date.__experimentalGetSettings', {\n\t\tsince: '6.1',\n\t\talternative: 'wp.date.getSettings',\n\t} );\n\treturn getSettings();\n}\n\nfunction setupWPTimezone() {\n\t// Get the current timezone settings from the WP timezone string.\n\tconst currentTimezone = momentLib.tz.zone( settings.timezone.string );\n\n\t// 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.\n\tif ( currentTimezone ) {\n\t\t// Create WP timezone based off settings.timezone.string. We need to include the additional data so that we\n\t\t// don't lose information about daylight savings time and other items.\n\t\t// See https://github.com/WordPress/gutenberg/pull/48083\n\t\tmomentLib.tz.add(\n\t\t\tmomentLib.tz.pack( {\n\t\t\t\tname: WP_ZONE,\n\t\t\t\tabbrs: currentTimezone.abbrs,\n\t\t\t\tuntils: currentTimezone.untils,\n\t\t\t\toffsets: currentTimezone.offsets,\n\t\t\t} )\n\t\t);\n\t} else {\n\t\t// Create WP timezone based off dateSettings.\n\t\tmomentLib.tz.add(\n\t\t\tmomentLib.tz.pack( {\n\t\t\t\tname: WP_ZONE,\n\t\t\t\tabbrs: [ WP_ZONE ],\n\t\t\t\tuntils: [ null ],\n\t\t\t\toffsets: [ -settings.timezone.offset * 60 || 0 ],\n\t\t\t} )\n\t\t);\n\t}\n}\n\n// Date constants.\n/**\n * Number of seconds in one minute.\n */\nconst MINUTE_IN_SECONDS = 60;\n/**\n * Number of minutes in one hour.\n */\nconst HOUR_IN_MINUTES = 60;\n/**\n * Number of seconds in one hour.\n */\nconst HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;\n\n/**\n * Map of PHP formats to Moment.js formats.\n *\n * These are used internally by {@link format}, and are either\n * a string representing the corresponding Moment.js format code, or a\n * function which returns the formatted string.\n *\n * This should only be used through {@link format}, not\n * directly.\n */\nconst formatMap = {\n\t// Day.\n\td: 'DD',\n\tD: 'ddd',\n\tj: 'D',\n\tl: 'dddd',\n\tN: 'E',\n\n\t/**\n\t * Gets the ordinal suffix.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tS( momentDate: Moment ) {\n\t\t// Do - D.\n\t\tconst num = momentDate.format( 'D' );\n\t\tconst withOrdinal = momentDate.format( 'Do' );\n\t\treturn withOrdinal.replace( num, '' );\n\t},\n\n\tw: 'd',\n\t/**\n\t * Gets the day of the year (zero-indexed).\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tz( momentDate: Moment ) {\n\t\t// DDD - 1.\n\t\treturn ( parseInt( momentDate.format( 'DDD' ), 10 ) - 1 ).toString();\n\t},\n\n\t// Week.\n\tW: 'W',\n\n\t// Month.\n\tF: 'MMMM',\n\tm: 'MM',\n\tM: 'MMM',\n\tn: 'M',\n\t/**\n\t * Gets the days in the month.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tt( momentDate: Moment ) {\n\t\treturn momentDate.daysInMonth();\n\t},\n\n\t// Year.\n\t/**\n\t * Gets whether the current year is a leap year.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tL( momentDate: Moment ) {\n\t\treturn momentDate.isLeapYear() ? '1' : '0';\n\t},\n\to: 'GGGG',\n\tY: 'YYYY',\n\ty: 'YY',\n\n\t// Time.\n\ta: 'a',\n\tA: 'A',\n\t/**\n\t * Gets the current time in Swatch Internet Time (.beats).\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tB( momentDate: Moment ) {\n\t\tconst timezoned = momentLib( momentDate ).utcOffset( 60 );\n\t\tconst seconds = parseInt( timezoned.format( 's' ), 10 ),\n\t\t\tminutes = parseInt( timezoned.format( 'm' ), 10 ),\n\t\t\thours = parseInt( timezoned.format( 'H' ), 10 );\n\t\treturn parseInt(\n\t\t\t(\n\t\t\t\t( seconds +\n\t\t\t\t\tminutes * MINUTE_IN_SECONDS +\n\t\t\t\t\thours * HOUR_IN_SECONDS ) /\n\t\t\t\t86.4\n\t\t\t).toString(),\n\t\t\t10\n\t\t);\n\t},\n\tg: 'h',\n\tG: 'H',\n\th: 'hh',\n\tH: 'HH',\n\ti: 'mm',\n\ts: 'ss',\n\tu: 'SSSSSS',\n\tv: 'SSS',\n\t// Timezone.\n\te: 'zz',\n\t/**\n\t * Gets whether the timezone is in DST currently.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tI( momentDate: Moment ) {\n\t\treturn momentDate.isDST() ? '1' : '0';\n\t},\n\tO: 'ZZ',\n\tP: 'Z',\n\tT: 'z',\n\t/**\n\t * Gets the timezone offset in seconds.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tZ( momentDate: Moment ) {\n\t\t// Timezone offset in seconds.\n\t\tconst offset = momentDate.format( 'Z' );\n\t\tconst sign = offset[ 0 ] === '-' ? -1 : 1;\n\t\tconst parts = offset\n\t\t\t.substring( 1 )\n\t\t\t.split( ':' )\n\t\t\t.map( ( n ) => parseInt( n, 10 ) );\n\t\treturn (\n\t\t\tsign *\n\t\t\t( parts[ 0 ] * HOUR_IN_MINUTES + parts[ 1 ] ) *\n\t\t\tMINUTE_IN_SECONDS\n\t\t);\n\t},\n\t// Full date/time.\n\tc: 'YYYY-MM-DDTHH:mm:ssZ', // .toISOString.\n\t/**\n\t * Formats the date as RFC2822.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tr( momentDate: Moment ) {\n\t\treturn momentDate\n\t\t\t.locale( 'en' )\n\t\t\t.format( 'ddd, DD MMM YYYY HH:mm:ss ZZ' );\n\t},\n\tU: 'X',\n};\n\n/**\n * Formats a date. Does not alter the date's timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date.\n */\nexport function format(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tlet i, char;\n\tconst newFormat = [];\n\tconst momentDate = momentLib( dateValue );\n\tfor ( i = 0; i < dateFormat.length; i++ ) {\n\t\tchar = dateFormat[ i ];\n\t\t// Is this an escape?\n\t\tif ( '\\\\' === char ) {\n\t\t\t// Add next character, then move on.\n\t\t\ti++;\n\t\t\tnewFormat.push( '[' + dateFormat[ i ] + ']' );\n\t\t\tcontinue;\n\t\t}\n\t\tif ( char in formatMap ) {\n\t\t\tconst formatter = formatMap[ char as keyof typeof formatMap ];\n\t\t\tif ( typeof formatter !== 'string' ) {\n\t\t\t\t// If the format is a function, call it.\n\t\t\t\tnewFormat.push( '[' + formatter( momentDate ) + ']' );\n\t\t\t} else {\n\t\t\t\t// Otherwise, add as a formatting string.\n\t\t\t\tnewFormat.push( formatter );\n\t\t\t}\n\t\t} else {\n\t\t\tnewFormat.push( '[' + char + ']' );\n\t\t}\n\t}\n\t// Join with [] between to separate characters, and replace\n\t// unneeded separators with static text.\n\treturn momentDate.format( newFormat.join( '[]' ) );\n}\n\n/**\n * Formats a date (like `date()` in PHP).\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string, parsable\n * by moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return {string} Formatted date in English.\n */\nexport function date(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date(),\n\ttimezone?: string\n) {\n\tconst dateMoment = buildMoment( dateValue, timezone );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `date()` in PHP), in the UTC timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date in English.\n */\nexport function gmdate(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tconst dateMoment = momentLib( dateValue ).utc();\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `wp_date()` in PHP), translating it into site's locale.\n *\n * Backward Compatibility Notice: if `timezone` is set to `true`, the function\n * behaves like `gmdateI18n`.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string, parsable by\n * moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site. Notice: `boolean` is effectively\n * deprecated, but still supported for\n * backward compatibility reasons.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return Formatted date.\n */\nexport function dateI18n(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date(),\n\ttimezone?: string | number | boolean\n) {\n\tif ( true === timezone ) {\n\t\treturn gmdateI18n( dateFormat, dateValue );\n\t}\n\n\tif ( false === timezone ) {\n\t\ttimezone = undefined;\n\t}\n\n\tconst dateMoment = buildMoment( dateValue, timezone );\n\tdateMoment.locale( settings.l10n.locale );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `wp_date()` in PHP), translating it into site's locale\n * and using the UTC timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date.\n */\nexport function gmdateI18n(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tconst dateMoment = momentLib( dateValue ).utc();\n\tdateMoment.locale( settings.l10n.locale );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Check whether a date is considered in the future according to the WordPress settings.\n *\n * @param dateValue Date String or Date object in the Defined WP Timezone.\n *\n * @return Is in the future.\n */\nexport function isInTheFuture( dateValue: Date | string | number ) {\n\tconst now = momentLib.tz( WP_ZONE );\n\tconst momentObject = momentLib.tz( dateValue, WP_ZONE );\n\n\treturn momentObject.isAfter( now );\n}\n\n/**\n * Create and return a JavaScript Date Object from a date string in the WP timezone.\n *\n * @param dateString Date formatted in the WP timezone.\n *\n * @return Date\n */\nexport function getDate( dateString?: string | null ) {\n\tif ( ! dateString ) {\n\t\treturn momentLib.tz( WP_ZONE ).toDate();\n\t}\n\n\treturn momentLib.tz( dateString, WP_ZONE ).toDate();\n}\n\n/**\n * Returns a human-readable time difference between two dates, like human_time_diff() in PHP.\n *\n * @param from From date, in the WP timezone.\n * @param to To date, formatted in the WP timezone.\n *\n * @return Human-readable time difference.\n */\nexport function humanTimeDiff(\n\tfrom: Moment | Date | string | number,\n\tto?: Moment | Date | string | number\n) {\n\tconst fromMoment = momentLib.tz( from, WP_ZONE );\n\tconst toMoment = to ? momentLib.tz( to, WP_ZONE ) : momentLib.tz( WP_ZONE );\n\treturn fromMoment.from( toMoment );\n}\n\n/**\n * Creates a moment instance using the given timezone or, if none is provided, using global settings.\n *\n * @param dateValue Date object or string, parsable\n * by moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return A moment instance.\n */\nfunction buildMoment(\n\tdateValue?: Moment | Date | string | number,\n\ttimezone: string | number = ''\n) {\n\tconst dateMoment = momentLib( dateValue );\n\n\tif ( timezone !== '' ) {\n\t\treturn isUTCOffset( timezone )\n\t\t\t? dateMoment.utcOffset( timezone )\n\t\t\t: // A false isUTCOffset() guarantees that timezone is a string.\n\t\t\t dateMoment.tz( timezone as string );\n\t}\n\n\tif ( settings.timezone.string ) {\n\t\treturn dateMoment.tz( settings.timezone.string );\n\t}\n\n\treturn dateMoment.utcOffset( +settings.timezone.offset );\n}\n\n/**\n * Returns whether a certain UTC offset is valid or not.\n *\n * @param offset a UTC offset.\n *\n * @return whether a certain UTC offset is valid or not.\n */\nfunction isUTCOffset( offset: number | string ) {\n\tif ( 'number' === typeof offset ) {\n\t\treturn true;\n\t}\n\n\treturn VALID_UTC_OFFSET.test( offset );\n}\n\nsetupWPTimezone();\n"],
5
- "mappings": ";AAIA,OAAO,eAAe;AACtB,OAAO;AACP,OAAO;AAKP,OAAO,gBAAgB;AAQvB,IAAM,UAAU;AAIhB,IAAM,mBAAmB;AAIzB,IAAI,WAAyB;AAAA,EAC5B,MAAM;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA,aAAa;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA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WAAO,UAAU,GAAI,OAAQ,EAAE,OAAO;AAAA,EACvC;AAEA,SAAO,UAAU,GAAI,YAAY,OAAQ,EAAE,OAAO;AACnD;AAUO,SAAS,cACf,MACA,IACC;AACD,QAAM,aAAa,UAAU,GAAI,MAAM,OAAQ;AAC/C,QAAM,WAAW,KAAK,UAAU,GAAI,IAAI,OAAQ,IAAI,UAAU,GAAI,OAAQ;AAC1E,SAAO,WAAW,KAAM,QAAS;AAClC;AAgBA,SAAS,YACR,WACA,WAA4B,IAC3B;AACD,QAAM,aAAa,UAAW,SAAU;AAExC,MAAK,aAAa,IAAK;AACtB,WAAO,YAAa,QAAS,IAC1B,WAAW,UAAW,QAAS;AAAA;AAAA,MAE/B,WAAW,GAAI,QAAmB;AAAA;AAAA,EACtC;AAEA,MAAK,SAAS,SAAS,QAAS;AAC/B,WAAO,WAAW,GAAI,SAAS,SAAS,MAAO;AAAA,EAChD;AAEA,SAAO,WAAW,UAAW,CAAC,SAAS,SAAS,MAAO;AACxD;AASA,SAAS,YAAa,QAA0B;AAC/C,MAAK,aAAa,OAAO,QAAS;AACjC,WAAO;AAAA,EACR;AAEA,SAAO,iBAAiB,KAAM,MAAO;AACtC;AAEA,gBAAgB;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { Moment } from 'moment';\nimport momentLib from 'moment';\nimport 'moment-timezone/moment-timezone.js';\nimport 'moment-timezone/moment-timezone-utils.js';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n/**\n * Internal dependencies\n */\nimport type { DateSettings } from './types';\n\nexport type * from './types';\n\nconst WP_ZONE = 'WP';\n\n// This regular expression tests positive for UTC offsets as described in ISO 8601.\n// See: https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\nconst VALID_UTC_OFFSET = /^[+-][0-1][0-9](:?[0-9][0-9])?$/;\n\n// Changes made here will likely need to be synced with Core in the file\n// src/wp-includes/script-loader.php in `wp_default_packages_inline_scripts()`.\nlet settings: DateSettings = {\n\tl10n: {\n\t\tlocale: 'en',\n\t\tmonths: [\n\t\t\t'January',\n\t\t\t'February',\n\t\t\t'March',\n\t\t\t'April',\n\t\t\t'May',\n\t\t\t'June',\n\t\t\t'July',\n\t\t\t'August',\n\t\t\t'September',\n\t\t\t'October',\n\t\t\t'November',\n\t\t\t'December',\n\t\t],\n\t\tmonthsShort: [\n\t\t\t'Jan',\n\t\t\t'Feb',\n\t\t\t'Mar',\n\t\t\t'Apr',\n\t\t\t'May',\n\t\t\t'Jun',\n\t\t\t'Jul',\n\t\t\t'Aug',\n\t\t\t'Sep',\n\t\t\t'Oct',\n\t\t\t'Nov',\n\t\t\t'Dec',\n\t\t],\n\t\tweekdays: [\n\t\t\t'Sunday',\n\t\t\t'Monday',\n\t\t\t'Tuesday',\n\t\t\t'Wednesday',\n\t\t\t'Thursday',\n\t\t\t'Friday',\n\t\t\t'Saturday',\n\t\t],\n\t\tweekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],\n\t\tmeridiem: { am: 'am', pm: 'pm', AM: 'AM', PM: 'PM' },\n\t\trelative: {\n\t\t\tfuture: '%s from now',\n\t\t\tpast: '%s ago',\n\t\t\ts: 'a few seconds',\n\t\t\tss: '%d seconds',\n\t\t\tm: 'a minute',\n\t\t\tmm: '%d minutes',\n\t\t\th: 'an hour',\n\t\t\thh: '%d hours',\n\t\t\td: 'a day',\n\t\t\tdd: '%d days',\n\t\t\tM: 'a month',\n\t\t\tMM: '%d months',\n\t\t\ty: 'a year',\n\t\t\tyy: '%d years',\n\t\t},\n\t\tstartOfWeek: 0,\n\t},\n\tformats: {\n\t\ttime: 'g:i a',\n\t\tdate: 'F j, Y',\n\t\tdatetime: 'F j, Y g:i a',\n\t\tdatetimeAbbreviated: 'M j, Y g:i a',\n\t},\n\ttimezone: { offset: 0, offsetFormatted: '0', string: '', abbr: '' },\n};\n\n/**\n * Adds a locale to moment, using the format supplied by `wp_localize_script()`.\n *\n * @param dateSettings Settings, including locale data.\n */\nexport function setSettings( dateSettings: DateSettings ) {\n\tsettings = dateSettings;\n\n\tsetupWPTimezone();\n\n\t// Does moment already have a locale with the right name?\n\tif ( momentLib.locales().includes( dateSettings.l10n.locale ) ) {\n\t\t// Is that locale misconfigured, e.g. because we are on a site running\n\t\t// WordPress < 6.0?\n\t\tif (\n\t\t\tmomentLib\n\t\t\t\t.localeData( dateSettings.l10n.locale )\n\t\t\t\t.longDateFormat( 'LTS' ) === null\n\t\t) {\n\t\t\t// Delete the misconfigured locale.\n\t\t\t// @ts-ignore Type definitions are incorrect - null is permitted.\n\t\t\tmomentLib.defineLocale( dateSettings.l10n.locale, null );\n\t\t} else {\n\t\t\t// We have a properly configured locale, so no need to create one.\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// defineLocale() will modify the current locale, so back it up.\n\tconst currentLocale = momentLib.locale();\n\n\t// Create locale.\n\tmomentLib.defineLocale( dateSettings.l10n.locale, {\n\t\t// Inherit anything missing from English. We don't load\n\t\t// moment-with-locales.js so English is all there is.\n\t\tparentLocale: 'en',\n\t\tmonths: dateSettings.l10n.months,\n\t\tmonthsShort: dateSettings.l10n.monthsShort,\n\t\tweekdays: dateSettings.l10n.weekdays,\n\t\tweekdaysShort: dateSettings.l10n.weekdaysShort,\n\t\tmeridiem( hour, minute, isLowercase ) {\n\t\t\tif ( hour < 12 ) {\n\t\t\t\treturn isLowercase\n\t\t\t\t\t? dateSettings.l10n.meridiem.am\n\t\t\t\t\t: dateSettings.l10n.meridiem.AM;\n\t\t\t}\n\t\t\treturn isLowercase\n\t\t\t\t? dateSettings.l10n.meridiem.pm\n\t\t\t\t: dateSettings.l10n.meridiem.PM;\n\t\t},\n\t\tlongDateFormat: {\n\t\t\tLT: dateSettings.formats.time,\n\t\t\tLTS: momentLib.localeData( 'en' ).longDateFormat( 'LTS' ),\n\t\t\tL: momentLib.localeData( 'en' ).longDateFormat( 'L' ),\n\t\t\tLL: dateSettings.formats.date,\n\t\t\tLLL: dateSettings.formats.datetime,\n\t\t\tLLLL: momentLib.localeData( 'en' ).longDateFormat( 'LLLL' ),\n\t\t},\n\t\t// From human_time_diff?\n\t\t// Set to `(number, withoutSuffix, key, isFuture) => {}` instead.\n\t\trelativeTime: dateSettings.l10n.relative,\n\t} );\n\n\t// Restore the locale to what it was.\n\tmomentLib.locale( currentLocale );\n}\n\n/**\n * Returns the currently defined date settings.\n *\n * @return {DateSettings} Settings, including locale data.\n */\nexport function getSettings() {\n\treturn settings;\n}\n\n/**\n * Returns the currently defined date settings.\n *\n * @deprecated\n * @return {DateSettings} Settings, including locale data.\n */\nexport function __experimentalGetSettings() {\n\tdeprecated( 'wp.date.__experimentalGetSettings', {\n\t\tsince: '6.1',\n\t\talternative: 'wp.date.getSettings',\n\t} );\n\treturn getSettings();\n}\n\n// Cached packed zone string, used to re-add the WP zone without requiring\n// moment-timezone-utils (which provides .pack()) after a third-party plugin\n// reloads moment-timezone and destroys both the zone and the utils.\nlet wpZonePacked: string | undefined;\n\n/**\n * Ensures the custom WP timezone zone exists in moment-timezone's registry.\n *\n * Third-party plugins (e.g. WooCommerce) may load their own copy of\n * moment-timezone, which reinitializes the internal zone storage and\n * destroys the custom 'WP' zone. This function checks for the zone's\n * existence and re-creates it if necessary.\n */\nfunction ensureWPTimezone() {\n\tif ( ! momentLib.tz.zone( WP_ZONE ) ) {\n\t\tif ( wpZonePacked ) {\n\t\t\tmomentLib.tz.add( wpZonePacked );\n\t\t} else {\n\t\t\tsetupWPTimezone();\n\t\t}\n\t}\n}\n\nfunction setupWPTimezone() {\n\t// Get the current timezone settings from the WP timezone string.\n\tconst currentTimezone = momentLib.tz.zone( settings.timezone.string );\n\n\tlet packed;\n\t// 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.\n\tif ( currentTimezone ) {\n\t\t// Create WP timezone based off settings.timezone.string. We need to include the additional data so that we\n\t\t// don't lose information about daylight savings time and other items.\n\t\t// See https://github.com/WordPress/gutenberg/pull/48083\n\t\tpacked = momentLib.tz.pack( {\n\t\t\tname: WP_ZONE,\n\t\t\tabbrs: currentTimezone.abbrs,\n\t\t\tuntils: currentTimezone.untils,\n\t\t\toffsets: currentTimezone.offsets,\n\t\t} );\n\t} else {\n\t\t// Create WP timezone based off dateSettings.\n\t\tpacked = momentLib.tz.pack( {\n\t\t\tname: WP_ZONE,\n\t\t\tabbrs: [ WP_ZONE ],\n\t\t\tuntils: [ null ],\n\t\t\toffsets: [ -settings.timezone.offset * 60 || 0 ],\n\t\t} );\n\t}\n\n\twpZonePacked = packed;\n\tmomentLib.tz.add( packed );\n}\n\n// Date constants.\n/**\n * Number of seconds in one minute.\n */\nconst MINUTE_IN_SECONDS = 60;\n/**\n * Number of minutes in one hour.\n */\nconst HOUR_IN_MINUTES = 60;\n/**\n * Number of seconds in one hour.\n */\nconst HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;\n\n/**\n * Map of PHP formats to Moment.js formats.\n *\n * These are used internally by {@link format}, and are either\n * a string representing the corresponding Moment.js format code, or a\n * function which returns the formatted string.\n *\n * This should only be used through {@link format}, not\n * directly.\n */\nconst formatMap = {\n\t// Day.\n\td: 'DD',\n\tD: 'ddd',\n\tj: 'D',\n\tl: 'dddd',\n\tN: 'E',\n\n\t/**\n\t * Gets the ordinal suffix.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tS( momentDate: Moment ) {\n\t\t// Do - D.\n\t\tconst num = momentDate.format( 'D' );\n\t\tconst withOrdinal = momentDate.format( 'Do' );\n\t\treturn withOrdinal.replace( num, '' );\n\t},\n\n\tw: 'd',\n\t/**\n\t * Gets the day of the year (zero-indexed).\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tz( momentDate: Moment ) {\n\t\t// DDD - 1.\n\t\treturn ( parseInt( momentDate.format( 'DDD' ), 10 ) - 1 ).toString();\n\t},\n\n\t// Week.\n\tW: 'W',\n\n\t// Month.\n\tF: 'MMMM',\n\tm: 'MM',\n\tM: 'MMM',\n\tn: 'M',\n\t/**\n\t * Gets the days in the month.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tt( momentDate: Moment ) {\n\t\treturn momentDate.daysInMonth();\n\t},\n\n\t// Year.\n\t/**\n\t * Gets whether the current year is a leap year.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tL( momentDate: Moment ) {\n\t\treturn momentDate.isLeapYear() ? '1' : '0';\n\t},\n\to: 'GGGG',\n\tY: 'YYYY',\n\ty: 'YY',\n\n\t// Time.\n\ta: 'a',\n\tA: 'A',\n\t/**\n\t * Gets the current time in Swatch Internet Time (.beats).\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tB( momentDate: Moment ) {\n\t\tconst timezoned = momentLib( momentDate ).utcOffset( 60 );\n\t\tconst seconds = parseInt( timezoned.format( 's' ), 10 ),\n\t\t\tminutes = parseInt( timezoned.format( 'm' ), 10 ),\n\t\t\thours = parseInt( timezoned.format( 'H' ), 10 );\n\t\treturn parseInt(\n\t\t\t(\n\t\t\t\t( seconds +\n\t\t\t\t\tminutes * MINUTE_IN_SECONDS +\n\t\t\t\t\thours * HOUR_IN_SECONDS ) /\n\t\t\t\t86.4\n\t\t\t).toString(),\n\t\t\t10\n\t\t);\n\t},\n\tg: 'h',\n\tG: 'H',\n\th: 'hh',\n\tH: 'HH',\n\ti: 'mm',\n\ts: 'ss',\n\tu: 'SSSSSS',\n\tv: 'SSS',\n\t// Timezone.\n\te: 'zz',\n\t/**\n\t * Gets whether the timezone is in DST currently.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tI( momentDate: Moment ) {\n\t\treturn momentDate.isDST() ? '1' : '0';\n\t},\n\tO: 'ZZ',\n\tP: 'Z',\n\tT: 'z',\n\t/**\n\t * Gets the timezone offset in seconds.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tZ( momentDate: Moment ) {\n\t\t// Timezone offset in seconds.\n\t\tconst offset = momentDate.format( 'Z' );\n\t\tconst sign = offset[ 0 ] === '-' ? -1 : 1;\n\t\tconst parts = offset\n\t\t\t.substring( 1 )\n\t\t\t.split( ':' )\n\t\t\t.map( ( n ) => parseInt( n, 10 ) );\n\t\treturn (\n\t\t\tsign *\n\t\t\t( parts[ 0 ] * HOUR_IN_MINUTES + parts[ 1 ] ) *\n\t\t\tMINUTE_IN_SECONDS\n\t\t);\n\t},\n\t// Full date/time.\n\tc: 'YYYY-MM-DDTHH:mm:ssZ', // .toISOString.\n\t/**\n\t * Formats the date as RFC2822.\n\t *\n\t * @param momentDate Moment instance.\n\t *\n\t * @return Formatted date.\n\t */\n\tr( momentDate: Moment ) {\n\t\treturn momentDate\n\t\t\t.locale( 'en' )\n\t\t\t.format( 'ddd, DD MMM YYYY HH:mm:ss ZZ' );\n\t},\n\tU: 'X',\n};\n\n/**\n * Formats a date. Does not alter the date's timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date.\n */\nexport function format(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tlet i, char;\n\tconst newFormat = [];\n\tconst momentDate = momentLib( dateValue );\n\tfor ( i = 0; i < dateFormat.length; i++ ) {\n\t\tchar = dateFormat[ i ];\n\t\t// Is this an escape?\n\t\tif ( '\\\\' === char ) {\n\t\t\t// Add next character, then move on.\n\t\t\ti++;\n\t\t\tnewFormat.push( '[' + dateFormat[ i ] + ']' );\n\t\t\tcontinue;\n\t\t}\n\t\tif ( char in formatMap ) {\n\t\t\tconst formatter = formatMap[ char as keyof typeof formatMap ];\n\t\t\tif ( typeof formatter !== 'string' ) {\n\t\t\t\t// If the format is a function, call it.\n\t\t\t\tnewFormat.push( '[' + formatter( momentDate ) + ']' );\n\t\t\t} else {\n\t\t\t\t// Otherwise, add as a formatting string.\n\t\t\t\tnewFormat.push( formatter );\n\t\t\t}\n\t\t} else {\n\t\t\tnewFormat.push( '[' + char + ']' );\n\t\t}\n\t}\n\t// Join with [] between to separate characters, and replace\n\t// unneeded separators with static text.\n\treturn momentDate.format( newFormat.join( '[]' ) );\n}\n\n/**\n * Formats a date (like `date()` in PHP).\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string, parsable\n * by moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return {string} Formatted date in English.\n */\nexport function date(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date(),\n\ttimezone?: string\n) {\n\tconst dateMoment = buildMoment( dateValue, timezone );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `date()` in PHP), in the UTC timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date in English.\n */\nexport function gmdate(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tconst dateMoment = momentLib( dateValue ).utc();\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `wp_date()` in PHP), translating it into site's locale.\n *\n * Backward Compatibility Notice: if `timezone` is set to `true`, the function\n * behaves like `gmdateI18n`.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string, parsable by\n * moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site. Notice: `boolean` is effectively\n * deprecated, but still supported for\n * backward compatibility reasons.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return Formatted date.\n */\nexport function dateI18n(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date(),\n\ttimezone?: string | number | boolean\n) {\n\tif ( true === timezone ) {\n\t\treturn gmdateI18n( dateFormat, dateValue );\n\t}\n\n\tif ( false === timezone ) {\n\t\ttimezone = undefined;\n\t}\n\n\tconst dateMoment = buildMoment( dateValue, timezone );\n\tdateMoment.locale( settings.l10n.locale );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Formats a date (like `wp_date()` in PHP), translating it into site's locale\n * and using the UTC timezone.\n *\n * @param dateFormat PHP-style formatting string.\n * See [php.net/date](https://www.php.net/manual/en/function.date.php).\n * @param dateValue Date object or string,\n * parsable by moment.js.\n *\n * @return Formatted date.\n */\nexport function gmdateI18n(\n\tdateFormat: string,\n\tdateValue: Moment | Date | string | number = new Date()\n) {\n\tconst dateMoment = momentLib( dateValue ).utc();\n\tdateMoment.locale( settings.l10n.locale );\n\treturn format( dateFormat, dateMoment );\n}\n\n/**\n * Check whether a date is considered in the future according to the WordPress settings.\n *\n * @param dateValue Date String or Date object in the Defined WP Timezone.\n *\n * @return Is in the future.\n */\nexport function isInTheFuture( dateValue: Date | string | number ) {\n\tensureWPTimezone();\n\tconst now = momentLib.tz( WP_ZONE );\n\tconst momentObject = momentLib.tz( dateValue, WP_ZONE );\n\n\treturn momentObject.isAfter( now );\n}\n\n/**\n * Create and return a JavaScript Date Object from a date string in the WP timezone.\n *\n * @param dateString Date formatted in the WP timezone.\n *\n * @return Date\n */\nexport function getDate( dateString?: string | null ) {\n\tensureWPTimezone();\n\tif ( ! dateString ) {\n\t\treturn momentLib.tz( WP_ZONE ).toDate();\n\t}\n\n\treturn momentLib.tz( dateString, WP_ZONE ).toDate();\n}\n\n/**\n * Returns a human-readable time difference between two dates, like human_time_diff() in PHP.\n *\n * @param from From date, in the WP timezone.\n * @param to To date, formatted in the WP timezone.\n *\n * @return Human-readable time difference.\n */\nexport function humanTimeDiff(\n\tfrom: Moment | Date | string | number,\n\tto?: Moment | Date | string | number\n) {\n\tensureWPTimezone();\n\tconst fromMoment = momentLib.tz( from, WP_ZONE );\n\tconst toMoment = to ? momentLib.tz( to, WP_ZONE ) : momentLib.tz( WP_ZONE );\n\treturn fromMoment.from( toMoment );\n}\n\n/**\n * Creates a moment instance using the given timezone or, if none is provided, using global settings.\n *\n * @param dateValue Date object or string, parsable\n * by moment.js.\n * @param timezone Timezone to output result in or a\n * UTC offset. Defaults to timezone from\n * site.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC\n *\n * @return A moment instance.\n */\nfunction buildMoment(\n\tdateValue?: Moment | Date | string | number,\n\ttimezone: string | number = ''\n) {\n\tconst dateMoment = momentLib( dateValue );\n\n\tif ( timezone !== '' ) {\n\t\treturn isUTCOffset( timezone )\n\t\t\t? dateMoment.utcOffset( timezone )\n\t\t\t: // A false isUTCOffset() guarantees that timezone is a string.\n\t\t\t dateMoment.tz( timezone as string );\n\t}\n\n\tif ( settings.timezone.string ) {\n\t\treturn dateMoment.tz( settings.timezone.string );\n\t}\n\n\treturn dateMoment.utcOffset( +settings.timezone.offset );\n}\n\n/**\n * Returns whether a certain UTC offset is valid or not.\n *\n * @param offset a UTC offset.\n *\n * @return whether a certain UTC offset is valid or not.\n */\nfunction isUTCOffset( offset: number | string ) {\n\tif ( 'number' === typeof offset ) {\n\t\treturn true;\n\t}\n\n\treturn VALID_UTC_OFFSET.test( offset );\n}\n\nsetupWPTimezone();\n"],
5
+ "mappings": ";AAIA,OAAO,eAAe;AACtB,OAAO;AACP,OAAO;AAKP,OAAO,gBAAgB;AAQvB,IAAM,UAAU;AAIhB,IAAM,mBAAmB;AAIzB,IAAI,WAAyB;AAAA,EAC5B,MAAM;AAAA,IACL,QA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AM,CACrB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAmB,UAIvD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CACvB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAmB,EACvD,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,UAapC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACzB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAmB,UAKvD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAE,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,WAM/D;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,QAOlD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,EACrC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,UAMpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/date",
3
- "version": "5.42.0",
3
+ "version": "5.43.1-next.v.202604091042.0+668146787",
4
4
  "description": "Date module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -43,12 +43,12 @@
43
43
  "wpScript": true,
44
44
  "types": "build-types",
45
45
  "dependencies": {
46
- "@wordpress/deprecated": "^4.42.0",
46
+ "@wordpress/deprecated": "^4.43.1-next.v.202604091042.0+668146787",
47
47
  "moment": "^2.29.4",
48
48
  "moment-timezone": "^0.5.40"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "c20787b1778ae64c2db65643b1c236309d68e6ba"
53
+ "gitHead": "73606df74f1c38a084bfa5db97205259ef817593"
54
54
  }
package/src/index.ts CHANGED
@@ -184,34 +184,57 @@ export function __experimentalGetSettings() {
184
184
  return getSettings();
185
185
  }
186
186
 
187
+ // Cached packed zone string, used to re-add the WP zone without requiring
188
+ // moment-timezone-utils (which provides .pack()) after a third-party plugin
189
+ // reloads moment-timezone and destroys both the zone and the utils.
190
+ let wpZonePacked: string | undefined;
191
+
192
+ /**
193
+ * Ensures the custom WP timezone zone exists in moment-timezone's registry.
194
+ *
195
+ * Third-party plugins (e.g. WooCommerce) may load their own copy of
196
+ * moment-timezone, which reinitializes the internal zone storage and
197
+ * destroys the custom 'WP' zone. This function checks for the zone's
198
+ * existence and re-creates it if necessary.
199
+ */
200
+ function ensureWPTimezone() {
201
+ if ( ! momentLib.tz.zone( WP_ZONE ) ) {
202
+ if ( wpZonePacked ) {
203
+ momentLib.tz.add( wpZonePacked );
204
+ } else {
205
+ setupWPTimezone();
206
+ }
207
+ }
208
+ }
209
+
187
210
  function setupWPTimezone() {
188
211
  // Get the current timezone settings from the WP timezone string.
189
212
  const currentTimezone = momentLib.tz.zone( settings.timezone.string );
190
213
 
214
+ let packed;
191
215
  // 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.
192
216
  if ( currentTimezone ) {
193
217
  // Create WP timezone based off settings.timezone.string. We need to include the additional data so that we
194
218
  // don't lose information about daylight savings time and other items.
195
219
  // See https://github.com/WordPress/gutenberg/pull/48083
196
- momentLib.tz.add(
197
- momentLib.tz.pack( {
198
- name: WP_ZONE,
199
- abbrs: currentTimezone.abbrs,
200
- untils: currentTimezone.untils,
201
- offsets: currentTimezone.offsets,
202
- } )
203
- );
220
+ packed = momentLib.tz.pack( {
221
+ name: WP_ZONE,
222
+ abbrs: currentTimezone.abbrs,
223
+ untils: currentTimezone.untils,
224
+ offsets: currentTimezone.offsets,
225
+ } );
204
226
  } else {
205
227
  // Create WP timezone based off dateSettings.
206
- momentLib.tz.add(
207
- momentLib.tz.pack( {
208
- name: WP_ZONE,
209
- abbrs: [ WP_ZONE ],
210
- untils: [ null ],
211
- offsets: [ -settings.timezone.offset * 60 || 0 ],
212
- } )
213
- );
228
+ packed = momentLib.tz.pack( {
229
+ name: WP_ZONE,
230
+ abbrs: [ WP_ZONE ],
231
+ untils: [ null ],
232
+ offsets: [ -settings.timezone.offset * 60 || 0 ],
233
+ } );
214
234
  }
235
+
236
+ wpZonePacked = packed;
237
+ momentLib.tz.add( packed );
215
238
  }
216
239
 
217
240
  // Date constants.
@@ -547,6 +570,7 @@ export function gmdateI18n(
547
570
  * @return Is in the future.
548
571
  */
549
572
  export function isInTheFuture( dateValue: Date | string | number ) {
573
+ ensureWPTimezone();
550
574
  const now = momentLib.tz( WP_ZONE );
551
575
  const momentObject = momentLib.tz( dateValue, WP_ZONE );
552
576
 
@@ -561,6 +585,7 @@ export function isInTheFuture( dateValue: Date | string | number ) {
561
585
  * @return Date
562
586
  */
563
587
  export function getDate( dateString?: string | null ) {
588
+ ensureWPTimezone();
564
589
  if ( ! dateString ) {
565
590
  return momentLib.tz( WP_ZONE ).toDate();
566
591
  }
@@ -580,6 +605,7 @@ export function humanTimeDiff(
580
605
  from: Moment | Date | string | number,
581
606
  to?: Moment | Date | string | number
582
607
  ) {
608
+ ensureWPTimezone();
583
609
  const fromMoment = momentLib.tz( from, WP_ZONE );
584
610
  const toMoment = to ? momentLib.tz( to, WP_ZONE ) : momentLib.tz( WP_ZONE );
585
611
  return fromMoment.from( toMoment );
package/src/test/index.js CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import momentLib from 'moment';
5
+
1
6
  /**
2
7
  * Internal dependencies
3
8
  */
@@ -683,3 +688,66 @@ describe( 'Moment.js Localization', () => {
683
688
  } );
684
689
  } );
685
690
  } );
691
+
692
+ describe( 'WP timezone zone recovery', () => {
693
+ // Simulate what happens when a third-party plugin (e.g. WooCommerce)
694
+ // loads its own copy of moment-timezone, which reinitializes the
695
+ // internal zone storage and destroys the custom 'WP' zone.
696
+ function destroyWPZone() {
697
+ // moment-timezone stores zones in an internal object.
698
+ // Removing 'wp' simulates a third-party moment-timezone reload.
699
+ const zones = momentLib.tz._zones;
700
+ delete zones.wp;
701
+ }
702
+
703
+ it( 'getDate should recover after WP zone is lost', () => {
704
+ const settings = getSettings();
705
+ setSettings( {
706
+ ...settings,
707
+ timezone: { offset: 4, string: '' },
708
+ } );
709
+
710
+ destroyWPZone();
711
+
712
+ // Should not throw and should return a valid date.
713
+ const result = getDate( '2024-01-15T10:00:00' );
714
+ expect( result ).toBeInstanceOf( Date );
715
+ expect( result.getTime() ).not.toBeNaN();
716
+
717
+ setSettings( settings );
718
+ } );
719
+
720
+ it( 'isInTheFuture should recover after WP zone is lost', () => {
721
+ const settings = getSettings();
722
+ setSettings( {
723
+ ...settings,
724
+ timezone: { offset: 4, string: '' },
725
+ } );
726
+
727
+ destroyWPZone();
728
+
729
+ // Create a date far in the future.
730
+ const futureDate = new Date( Date.now() + 1000 * 60 * 60 * 24 * 365 );
731
+ expect( isInTheFuture( futureDate ) ).toBe( true );
732
+
733
+ setSettings( settings );
734
+ } );
735
+
736
+ it( 'humanTimeDiff should recover after WP zone is lost', () => {
737
+ const settings = getSettings();
738
+ setSettings( {
739
+ ...settings,
740
+ timezone: { offset: 4, string: '' },
741
+ } );
742
+
743
+ destroyWPZone();
744
+
745
+ const result = humanTimeDiff(
746
+ '2023-04-28T11:00:00.000Z',
747
+ '2023-04-28T12:00:00.000Z'
748
+ );
749
+ expect( result ).toBe( 'an hour ago' );
750
+
751
+ setSettings( settings );
752
+ } );
753
+ } );