You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1776 lines
798 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 7812:
  4. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  5. var moment = module.exports = __webpack_require__(2828);
  6. moment.tz.load(__webpack_require__(1128));
  7. /***/ }),
  8. /***/ 9971:
  9. /***/ (function(module, exports, __webpack_require__) {
  10. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;//! moment-timezone-utils.js
  11. //! version : 0.5.40
  12. //! Copyright (c) JS Foundation and other contributors
  13. //! license : MIT
  14. //! github.com/moment/moment-timezone
  15. (function (root, factory) {
  16. "use strict";
  17. /*global define*/
  18. if ( true && module.exports) {
  19. module.exports = factory(__webpack_require__(7812)); // Node
  20. } else if (true) {
  21. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(6292)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  22. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  23. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  24. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); // AMD
  25. } else {}
  26. }(this, function (moment) {
  27. "use strict";
  28. if (!moment.tz) {
  29. throw new Error("moment-timezone-utils.js must be loaded after moment-timezone.js");
  30. }
  31. /************************************
  32. Pack Base 60
  33. ************************************/
  34. var BASE60 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX',
  35. EPSILON = 0.000001; // Used to fix floating point rounding errors
  36. function packBase60Fraction(fraction, precision) {
  37. var buffer = '.',
  38. output = '',
  39. current;
  40. while (precision > 0) {
  41. precision -= 1;
  42. fraction *= 60;
  43. current = Math.floor(fraction + EPSILON);
  44. buffer += BASE60[current];
  45. fraction -= current;
  46. // Only add buffer to output once we have a non-zero value.
  47. // This makes '.000' output '', and '.100' output '.1'
  48. if (current) {
  49. output += buffer;
  50. buffer = '';
  51. }
  52. }
  53. return output;
  54. }
  55. function packBase60(number, precision) {
  56. var output = '',
  57. absolute = Math.abs(number),
  58. whole = Math.floor(absolute),
  59. fraction = packBase60Fraction(absolute - whole, Math.min(~~precision, 10));
  60. while (whole > 0) {
  61. output = BASE60[whole % 60] + output;
  62. whole = Math.floor(whole / 60);
  63. }
  64. if (number < 0) {
  65. output = '-' + output;
  66. }
  67. if (output && fraction) {
  68. return output + fraction;
  69. }
  70. if (!fraction && output === '-') {
  71. return '0';
  72. }
  73. return output || fraction || '0';
  74. }
  75. /************************************
  76. Pack
  77. ************************************/
  78. function packUntils(untils) {
  79. var out = [],
  80. last = 0,
  81. i;
  82. for (i = 0; i < untils.length - 1; i++) {
  83. out[i] = packBase60(Math.round((untils[i] - last) / 1000) / 60, 1);
  84. last = untils[i];
  85. }
  86. return out.join(' ');
  87. }
  88. function packAbbrsAndOffsets(source) {
  89. var index = 0,
  90. abbrs = [],
  91. offsets = [],
  92. indices = [],
  93. map = {},
  94. i, key;
  95. for (i = 0; i < source.abbrs.length; i++) {
  96. key = source.abbrs[i] + '|' + source.offsets[i];
  97. if (map[key] === undefined) {
  98. map[key] = index;
  99. abbrs[index] = source.abbrs[i];
  100. offsets[index] = packBase60(Math.round(source.offsets[i] * 60) / 60, 1);
  101. index++;
  102. }
  103. indices[i] = packBase60(map[key], 0);
  104. }
  105. return abbrs.join(' ') + '|' + offsets.join(' ') + '|' + indices.join('');
  106. }
  107. function packPopulation (number) {
  108. if (!number) {
  109. return '';
  110. }
  111. if (number < 1000) {
  112. return number;
  113. }
  114. var exponent = String(number | 0).length - 2;
  115. var precision = Math.round(number / Math.pow(10, exponent));
  116. return precision + 'e' + exponent;
  117. }
  118. function packCountries (countries) {
  119. if (!countries) {
  120. return '';
  121. }
  122. return countries.join(' ');
  123. }
  124. function validatePackData (source) {
  125. if (!source.name) { throw new Error("Missing name"); }
  126. if (!source.abbrs) { throw new Error("Missing abbrs"); }
  127. if (!source.untils) { throw new Error("Missing untils"); }
  128. if (!source.offsets) { throw new Error("Missing offsets"); }
  129. if (
  130. source.offsets.length !== source.untils.length ||
  131. source.offsets.length !== source.abbrs.length
  132. ) {
  133. throw new Error("Mismatched array lengths");
  134. }
  135. }
  136. function pack (source) {
  137. validatePackData(source);
  138. return [
  139. source.name, // 0 - timezone name
  140. packAbbrsAndOffsets(source), // 1 - abbrs, 2 - offsets, 3 - indices
  141. packUntils(source.untils), // 4 - untils
  142. packPopulation(source.population) // 5 - population
  143. ].join('|');
  144. }
  145. function packCountry (source) {
  146. return [
  147. source.name,
  148. source.zones.join(' '),
  149. ].join('|');
  150. }
  151. /************************************
  152. Create Links
  153. ************************************/
  154. function arraysAreEqual(a, b) {
  155. var i;
  156. if (a.length !== b.length) { return false; }
  157. for (i = 0; i < a.length; i++) {
  158. if (a[i] !== b[i]) {
  159. return false;
  160. }
  161. }
  162. return true;
  163. }
  164. function zonesAreEqual(a, b) {
  165. return arraysAreEqual(a.offsets, b.offsets) && arraysAreEqual(a.abbrs, b.abbrs) && arraysAreEqual(a.untils, b.untils);
  166. }
  167. function findAndCreateLinks (input, output, links, groupLeaders) {
  168. var i, j, a, b, group, foundGroup, groups = [];
  169. for (i = 0; i < input.length; i++) {
  170. foundGroup = false;
  171. a = input[i];
  172. for (j = 0; j < groups.length; j++) {
  173. group = groups[j];
  174. b = group[0];
  175. if (zonesAreEqual(a, b)) {
  176. if (a.population > b.population) {
  177. group.unshift(a);
  178. } else if (a.population === b.population && groupLeaders && groupLeaders[a.name]) {
  179. group.unshift(a);
  180. } else {
  181. group.push(a);
  182. }
  183. foundGroup = true;
  184. }
  185. }
  186. if (!foundGroup) {
  187. groups.push([a]);
  188. }
  189. }
  190. for (i = 0; i < groups.length; i++) {
  191. group = groups[i];
  192. output.push(group[0]);
  193. for (j = 1; j < group.length; j++) {
  194. links.push(group[0].name + '|' + group[j].name);
  195. }
  196. }
  197. }
  198. function createLinks (source, groupLeaders) {
  199. var zones = [],
  200. links = [];
  201. if (source.links) {
  202. links = source.links.slice();
  203. }
  204. findAndCreateLinks(source.zones, zones, links, groupLeaders);
  205. return {
  206. version : source.version,
  207. zones : zones,
  208. links : links.sort()
  209. };
  210. }
  211. /************************************
  212. Filter Years
  213. ************************************/
  214. function findStartAndEndIndex (untils, start, end) {
  215. var startI = 0,
  216. endI = untils.length + 1,
  217. untilYear,
  218. i;
  219. if (!end) {
  220. end = start;
  221. }
  222. if (start > end) {
  223. i = start;
  224. start = end;
  225. end = i;
  226. }
  227. for (i = 0; i < untils.length; i++) {
  228. if (untils[i] == null) {
  229. continue;
  230. }
  231. untilYear = new Date(untils[i]).getUTCFullYear();
  232. if (untilYear < start) {
  233. startI = i + 1;
  234. }
  235. if (untilYear > end) {
  236. endI = Math.min(endI, i + 1);
  237. }
  238. }
  239. return [startI, endI];
  240. }
  241. function filterYears (source, start, end) {
  242. var slice = Array.prototype.slice,
  243. indices = findStartAndEndIndex(source.untils, start, end),
  244. untils = slice.apply(source.untils, indices);
  245. untils[untils.length - 1] = null;
  246. return {
  247. name : source.name,
  248. abbrs : slice.apply(source.abbrs, indices),
  249. untils : untils,
  250. offsets : slice.apply(source.offsets, indices),
  251. population : source.population,
  252. countries : source.countries
  253. };
  254. }
  255. /************************************
  256. Filter, Link, and Pack
  257. ************************************/
  258. function filterLinkPack (input, start, end, groupLeaders) {
  259. var i,
  260. inputZones = input.zones,
  261. outputZones = [],
  262. output;
  263. for (i = 0; i < inputZones.length; i++) {
  264. outputZones[i] = filterYears(inputZones[i], start, end);
  265. }
  266. output = createLinks({
  267. zones : outputZones,
  268. links : input.links.slice(),
  269. version : input.version
  270. }, groupLeaders);
  271. for (i = 0; i < output.zones.length; i++) {
  272. output.zones[i] = pack(output.zones[i]);
  273. }
  274. output.countries = input.countries ? input.countries.map(function (unpacked) {
  275. return packCountry(unpacked);
  276. }) : [];
  277. return output;
  278. }
  279. /************************************
  280. Exports
  281. ************************************/
  282. moment.tz.pack = pack;
  283. moment.tz.packBase60 = packBase60;
  284. moment.tz.createLinks = createLinks;
  285. moment.tz.filterYears = filterYears;
  286. moment.tz.filterLinkPack = filterLinkPack;
  287. moment.tz.packCountry = packCountry;
  288. return moment;
  289. }));
  290. /***/ }),
  291. /***/ 2828:
  292. /***/ (function(module, exports, __webpack_require__) {
  293. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;//! moment-timezone.js
  294. //! version : 0.5.40
  295. //! Copyright (c) JS Foundation and other contributors
  296. //! license : MIT
  297. //! github.com/moment/moment-timezone
  298. (function (root, factory) {
  299. "use strict";
  300. /*global define*/
  301. if ( true && module.exports) {
  302. module.exports = factory(__webpack_require__(6292)); // Node
  303. } else if (true) {
  304. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(6292)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  305. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  306. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  307. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); // AMD
  308. } else {}
  309. }(this, function (moment) {
  310. "use strict";
  311. // Resolves es6 module loading issue
  312. if (moment.version === undefined && moment.default) {
  313. moment = moment.default;
  314. }
  315. // Do not load moment-timezone a second time.
  316. // if (moment.tz !== undefined) {
  317. // logError('Moment Timezone ' + moment.tz.version + ' was already loaded ' + (moment.tz.dataVersion ? 'with data from ' : 'without any data') + moment.tz.dataVersion);
  318. // return moment;
  319. // }
  320. var VERSION = "0.5.40",
  321. zones = {},
  322. links = {},
  323. countries = {},
  324. names = {},
  325. guesses = {},
  326. cachedGuess;
  327. if (!moment || typeof moment.version !== 'string') {
  328. logError('Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/');
  329. }
  330. var momentVersion = moment.version.split('.'),
  331. major = +momentVersion[0],
  332. minor = +momentVersion[1];
  333. // Moment.js version check
  334. if (major < 2 || (major === 2 && minor < 6)) {
  335. logError('Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js ' + moment.version + '. See momentjs.com');
  336. }
  337. /************************************
  338. Unpacking
  339. ************************************/
  340. function charCodeToInt(charCode) {
  341. if (charCode > 96) {
  342. return charCode - 87;
  343. } else if (charCode > 64) {
  344. return charCode - 29;
  345. }
  346. return charCode - 48;
  347. }
  348. function unpackBase60(string) {
  349. var i = 0,
  350. parts = string.split('.'),
  351. whole = parts[0],
  352. fractional = parts[1] || '',
  353. multiplier = 1,
  354. num,
  355. out = 0,
  356. sign = 1;
  357. // handle negative numbers
  358. if (string.charCodeAt(0) === 45) {
  359. i = 1;
  360. sign = -1;
  361. }
  362. // handle digits before the decimal
  363. for (i; i < whole.length; i++) {
  364. num = charCodeToInt(whole.charCodeAt(i));
  365. out = 60 * out + num;
  366. }
  367. // handle digits after the decimal
  368. for (i = 0; i < fractional.length; i++) {
  369. multiplier = multiplier / 60;
  370. num = charCodeToInt(fractional.charCodeAt(i));
  371. out += num * multiplier;
  372. }
  373. return out * sign;
  374. }
  375. function arrayToInt (array) {
  376. for (var i = 0; i < array.length; i++) {
  377. array[i] = unpackBase60(array[i]);
  378. }
  379. }
  380. function intToUntil (array, length) {
  381. for (var i = 0; i < length; i++) {
  382. array[i] = Math.round((array[i - 1] || 0) + (array[i] * 60000)); // minutes to milliseconds
  383. }
  384. array[length - 1] = Infinity;
  385. }
  386. function mapIndices (source, indices) {
  387. var out = [], i;
  388. for (i = 0; i < indices.length; i++) {
  389. out[i] = source[indices[i]];
  390. }
  391. return out;
  392. }
  393. function unpack (string) {
  394. var data = string.split('|'),
  395. offsets = data[2].split(' '),
  396. indices = data[3].split(''),
  397. untils = data[4].split(' ');
  398. arrayToInt(offsets);
  399. arrayToInt(indices);
  400. arrayToInt(untils);
  401. intToUntil(untils, indices.length);
  402. return {
  403. name : data[0],
  404. abbrs : mapIndices(data[1].split(' '), indices),
  405. offsets : mapIndices(offsets, indices),
  406. untils : untils,
  407. population : data[5] | 0
  408. };
  409. }
  410. /************************************
  411. Zone object
  412. ************************************/
  413. function Zone (packedString) {
  414. if (packedString) {
  415. this._set(unpack(packedString));
  416. }
  417. }
  418. Zone.prototype = {
  419. _set : function (unpacked) {
  420. this.name = unpacked.name;
  421. this.abbrs = unpacked.abbrs;
  422. this.untils = unpacked.untils;
  423. this.offsets = unpacked.offsets;
  424. this.population = unpacked.population;
  425. },
  426. _index : function (timestamp) {
  427. var target = +timestamp,
  428. untils = this.untils,
  429. i;
  430. for (i = 0; i < untils.length; i++) {
  431. if (target < untils[i]) {
  432. return i;
  433. }
  434. }
  435. },
  436. countries : function () {
  437. var zone_name = this.name;
  438. return Object.keys(countries).filter(function (country_code) {
  439. return countries[country_code].zones.indexOf(zone_name) !== -1;
  440. });
  441. },
  442. parse : function (timestamp) {
  443. var target = +timestamp,
  444. offsets = this.offsets,
  445. untils = this.untils,
  446. max = untils.length - 1,
  447. offset, offsetNext, offsetPrev, i;
  448. for (i = 0; i < max; i++) {
  449. offset = offsets[i];
  450. offsetNext = offsets[i + 1];
  451. offsetPrev = offsets[i ? i - 1 : i];
  452. if (offset < offsetNext && tz.moveAmbiguousForward) {
  453. offset = offsetNext;
  454. } else if (offset > offsetPrev && tz.moveInvalidForward) {
  455. offset = offsetPrev;
  456. }
  457. if (target < untils[i] - (offset * 60000)) {
  458. return offsets[i];
  459. }
  460. }
  461. return offsets[max];
  462. },
  463. abbr : function (mom) {
  464. return this.abbrs[this._index(mom)];
  465. },
  466. offset : function (mom) {
  467. logError("zone.offset has been deprecated in favor of zone.utcOffset");
  468. return this.offsets[this._index(mom)];
  469. },
  470. utcOffset : function (mom) {
  471. return this.offsets[this._index(mom)];
  472. }
  473. };
  474. /************************************
  475. Country object
  476. ************************************/
  477. function Country (country_name, zone_names) {
  478. this.name = country_name;
  479. this.zones = zone_names;
  480. }
  481. /************************************
  482. Current Timezone
  483. ************************************/
  484. function OffsetAt(at) {
  485. var timeString = at.toTimeString();
  486. var abbr = timeString.match(/\([a-z ]+\)/i);
  487. if (abbr && abbr[0]) {
  488. // 17:56:31 GMT-0600 (CST)
  489. // 17:56:31 GMT-0600 (Central Standard Time)
  490. abbr = abbr[0].match(/[A-Z]/g);
  491. abbr = abbr ? abbr.join('') : undefined;
  492. } else {
  493. // 17:56:31 CST
  494. // 17:56:31 GMT+0800 (台北標準時間)
  495. abbr = timeString.match(/[A-Z]{3,5}/g);
  496. abbr = abbr ? abbr[0] : undefined;
  497. }
  498. if (abbr === 'GMT') {
  499. abbr = undefined;
  500. }
  501. this.at = +at;
  502. this.abbr = abbr;
  503. this.offset = at.getTimezoneOffset();
  504. }
  505. function ZoneScore(zone) {
  506. this.zone = zone;
  507. this.offsetScore = 0;
  508. this.abbrScore = 0;
  509. }
  510. ZoneScore.prototype.scoreOffsetAt = function (offsetAt) {
  511. this.offsetScore += Math.abs(this.zone.utcOffset(offsetAt.at) - offsetAt.offset);
  512. if (this.zone.abbr(offsetAt.at).replace(/[^A-Z]/g, '') !== offsetAt.abbr) {
  513. this.abbrScore++;
  514. }
  515. };
  516. function findChange(low, high) {
  517. var mid, diff;
  518. while ((diff = ((high.at - low.at) / 12e4 | 0) * 6e4)) {
  519. mid = new OffsetAt(new Date(low.at + diff));
  520. if (mid.offset === low.offset) {
  521. low = mid;
  522. } else {
  523. high = mid;
  524. }
  525. }
  526. return low;
  527. }
  528. function userOffsets() {
  529. var startYear = new Date().getFullYear() - 2,
  530. last = new OffsetAt(new Date(startYear, 0, 1)),
  531. offsets = [last],
  532. change, next, i;
  533. for (i = 1; i < 48; i++) {
  534. next = new OffsetAt(new Date(startYear, i, 1));
  535. if (next.offset !== last.offset) {
  536. change = findChange(last, next);
  537. offsets.push(change);
  538. offsets.push(new OffsetAt(new Date(change.at + 6e4)));
  539. }
  540. last = next;
  541. }
  542. for (i = 0; i < 4; i++) {
  543. offsets.push(new OffsetAt(new Date(startYear + i, 0, 1)));
  544. offsets.push(new OffsetAt(new Date(startYear + i, 6, 1)));
  545. }
  546. return offsets;
  547. }
  548. function sortZoneScores (a, b) {
  549. if (a.offsetScore !== b.offsetScore) {
  550. return a.offsetScore - b.offsetScore;
  551. }
  552. if (a.abbrScore !== b.abbrScore) {
  553. return a.abbrScore - b.abbrScore;
  554. }
  555. if (a.zone.population !== b.zone.population) {
  556. return b.zone.population - a.zone.population;
  557. }
  558. return b.zone.name.localeCompare(a.zone.name);
  559. }
  560. function addToGuesses (name, offsets) {
  561. var i, offset;
  562. arrayToInt(offsets);
  563. for (i = 0; i < offsets.length; i++) {
  564. offset = offsets[i];
  565. guesses[offset] = guesses[offset] || {};
  566. guesses[offset][name] = true;
  567. }
  568. }
  569. function guessesForUserOffsets (offsets) {
  570. var offsetsLength = offsets.length,
  571. filteredGuesses = {},
  572. out = [],
  573. i, j, guessesOffset;
  574. for (i = 0; i < offsetsLength; i++) {
  575. guessesOffset = guesses[offsets[i].offset] || {};
  576. for (j in guessesOffset) {
  577. if (guessesOffset.hasOwnProperty(j)) {
  578. filteredGuesses[j] = true;
  579. }
  580. }
  581. }
  582. for (i in filteredGuesses) {
  583. if (filteredGuesses.hasOwnProperty(i)) {
  584. out.push(names[i]);
  585. }
  586. }
  587. return out;
  588. }
  589. function rebuildGuess () {
  590. // use Intl API when available and returning valid time zone
  591. try {
  592. var intlName = Intl.DateTimeFormat().resolvedOptions().timeZone;
  593. if (intlName && intlName.length > 3) {
  594. var name = names[normalizeName(intlName)];
  595. if (name) {
  596. return name;
  597. }
  598. logError("Moment Timezone found " + intlName + " from the Intl api, but did not have that data loaded.");
  599. }
  600. } catch (e) {
  601. // Intl unavailable, fall back to manual guessing.
  602. }
  603. var offsets = userOffsets(),
  604. offsetsLength = offsets.length,
  605. guesses = guessesForUserOffsets(offsets),
  606. zoneScores = [],
  607. zoneScore, i, j;
  608. for (i = 0; i < guesses.length; i++) {
  609. zoneScore = new ZoneScore(getZone(guesses[i]), offsetsLength);
  610. for (j = 0; j < offsetsLength; j++) {
  611. zoneScore.scoreOffsetAt(offsets[j]);
  612. }
  613. zoneScores.push(zoneScore);
  614. }
  615. zoneScores.sort(sortZoneScores);
  616. return zoneScores.length > 0 ? zoneScores[0].zone.name : undefined;
  617. }
  618. function guess (ignoreCache) {
  619. if (!cachedGuess || ignoreCache) {
  620. cachedGuess = rebuildGuess();
  621. }
  622. return cachedGuess;
  623. }
  624. /************************************
  625. Global Methods
  626. ************************************/
  627. function normalizeName (name) {
  628. return (name || '').toLowerCase().replace(/\//g, '_');
  629. }
  630. function addZone (packed) {
  631. var i, name, split, normalized;
  632. if (typeof packed === "string") {
  633. packed = [packed];
  634. }
  635. for (i = 0; i < packed.length; i++) {
  636. split = packed[i].split('|');
  637. name = split[0];
  638. normalized = normalizeName(name);
  639. zones[normalized] = packed[i];
  640. names[normalized] = name;
  641. addToGuesses(normalized, split[2].split(' '));
  642. }
  643. }
  644. function getZone (name, caller) {
  645. name = normalizeName(name);
  646. var zone = zones[name];
  647. var link;
  648. if (zone instanceof Zone) {
  649. return zone;
  650. }
  651. if (typeof zone === 'string') {
  652. zone = new Zone(zone);
  653. zones[name] = zone;
  654. return zone;
  655. }
  656. // Pass getZone to prevent recursion more than 1 level deep
  657. if (links[name] && caller !== getZone && (link = getZone(links[name], getZone))) {
  658. zone = zones[name] = new Zone();
  659. zone._set(link);
  660. zone.name = names[name];
  661. return zone;
  662. }
  663. return null;
  664. }
  665. function getNames () {
  666. var i, out = [];
  667. for (i in names) {
  668. if (names.hasOwnProperty(i) && (zones[i] || zones[links[i]]) && names[i]) {
  669. out.push(names[i]);
  670. }
  671. }
  672. return out.sort();
  673. }
  674. function getCountryNames () {
  675. return Object.keys(countries);
  676. }
  677. function addLink (aliases) {
  678. var i, alias, normal0, normal1;
  679. if (typeof aliases === "string") {
  680. aliases = [aliases];
  681. }
  682. for (i = 0; i < aliases.length; i++) {
  683. alias = aliases[i].split('|');
  684. normal0 = normalizeName(alias[0]);
  685. normal1 = normalizeName(alias[1]);
  686. links[normal0] = normal1;
  687. names[normal0] = alias[0];
  688. links[normal1] = normal0;
  689. names[normal1] = alias[1];
  690. }
  691. }
  692. function addCountries (data) {
  693. var i, country_code, country_zones, split;
  694. if (!data || !data.length) return;
  695. for (i = 0; i < data.length; i++) {
  696. split = data[i].split('|');
  697. country_code = split[0].toUpperCase();
  698. country_zones = split[1].split(' ');
  699. countries[country_code] = new Country(
  700. country_code,
  701. country_zones
  702. );
  703. }
  704. }
  705. function getCountry (name) {
  706. name = name.toUpperCase();
  707. return countries[name] || null;
  708. }
  709. function zonesForCountry(country, with_offset) {
  710. country = getCountry(country);
  711. if (!country) return null;
  712. var zones = country.zones.sort();
  713. if (with_offset) {
  714. return zones.map(function (zone_name) {
  715. var zone = getZone(zone_name);
  716. return {
  717. name: zone_name,
  718. offset: zone.utcOffset(new Date())
  719. };
  720. });
  721. }
  722. return zones;
  723. }
  724. function loadData (data) {
  725. addZone(data.zones);
  726. addLink(data.links);
  727. addCountries(data.countries);
  728. tz.dataVersion = data.version;
  729. }
  730. function zoneExists (name) {
  731. if (!zoneExists.didShowError) {
  732. zoneExists.didShowError = true;
  733. logError("moment.tz.zoneExists('" + name + "') has been deprecated in favor of !moment.tz.zone('" + name + "')");
  734. }
  735. return !!getZone(name);
  736. }
  737. function needsOffset (m) {
  738. var isUnixTimestamp = (m._f === 'X' || m._f === 'x');
  739. return !!(m._a && (m._tzm === undefined) && !isUnixTimestamp);
  740. }
  741. function logError (message) {
  742. if (typeof console !== 'undefined' && typeof console.error === 'function') {
  743. console.error(message);
  744. }
  745. }
  746. /************************************
  747. moment.tz namespace
  748. ************************************/
  749. function tz (input) {
  750. var args = Array.prototype.slice.call(arguments, 0, -1),
  751. name = arguments[arguments.length - 1],
  752. zone = getZone(name),
  753. out = moment.utc.apply(null, args);
  754. if (zone && !moment.isMoment(input) && needsOffset(out)) {
  755. out.add(zone.parse(out), 'minutes');
  756. }
  757. out.tz(name);
  758. return out;
  759. }
  760. tz.version = VERSION;
  761. tz.dataVersion = '';
  762. tz._zones = zones;
  763. tz._links = links;
  764. tz._names = names;
  765. tz._countries = countries;
  766. tz.add = addZone;
  767. tz.link = addLink;
  768. tz.load = loadData;
  769. tz.zone = getZone;
  770. tz.zoneExists = zoneExists; // deprecated in 0.1.0
  771. tz.guess = guess;
  772. tz.names = getNames;
  773. tz.Zone = Zone;
  774. tz.unpack = unpack;
  775. tz.unpackBase60 = unpackBase60;
  776. tz.needsOffset = needsOffset;
  777. tz.moveInvalidForward = true;
  778. tz.moveAmbiguousForward = false;
  779. tz.countries = getCountryNames;
  780. tz.zonesForCountry = zonesForCountry;
  781. /************************************
  782. Interface with Moment.js
  783. ************************************/
  784. var fn = moment.fn;
  785. moment.tz = tz;
  786. moment.defaultZone = null;
  787. moment.updateOffset = function (mom, keepTime) {
  788. var zone = moment.defaultZone,
  789. offset;
  790. if (mom._z === undefined) {
  791. if (zone && needsOffset(mom) && !mom._isUTC) {
  792. mom._d = moment.utc(mom._a)._d;
  793. mom.utc().add(zone.parse(mom), 'minutes');
  794. }
  795. mom._z = zone;
  796. }
  797. if (mom._z) {
  798. offset = mom._z.utcOffset(mom);
  799. if (Math.abs(offset) < 16) {
  800. offset = offset / 60;
  801. }
  802. if (mom.utcOffset !== undefined) {
  803. var z = mom._z;
  804. mom.utcOffset(-offset, keepTime);
  805. mom._z = z;
  806. } else {
  807. mom.zone(offset, keepTime);
  808. }
  809. }
  810. };
  811. fn.tz = function (name, keepTime) {
  812. if (name) {
  813. if (typeof name !== 'string') {
  814. throw new Error('Time zone name must be a string, got ' + name + ' [' + typeof name + ']');
  815. }
  816. this._z = getZone(name);
  817. if (this._z) {
  818. moment.updateOffset(this, keepTime);
  819. } else {
  820. logError("Moment Timezone has no data for " + name + ". See http://momentjs.com/timezone/docs/#/data-loading/.");
  821. }
  822. return this;
  823. }
  824. if (this._z) { return this._z.name; }
  825. };
  826. function abbrWrap (old) {
  827. return function () {
  828. if (this._z) { return this._z.abbr(this); }
  829. return old.call(this);
  830. };
  831. }
  832. function resetZoneWrap (old) {
  833. return function () {
  834. this._z = null;
  835. return old.apply(this, arguments);
  836. };
  837. }
  838. function resetZoneWrap2 (old) {
  839. return function () {
  840. if (arguments.length > 0) this._z = null;
  841. return old.apply(this, arguments);
  842. };
  843. }
  844. fn.zoneName = abbrWrap(fn.zoneName);
  845. fn.zoneAbbr = abbrWrap(fn.zoneAbbr);
  846. fn.utc = resetZoneWrap(fn.utc);
  847. fn.local = resetZoneWrap(fn.local);
  848. fn.utcOffset = resetZoneWrap2(fn.utcOffset);
  849. moment.tz.setDefault = function(name) {
  850. if (major < 2 || (major === 2 && minor < 9)) {
  851. logError('Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js ' + moment.version + '.');
  852. }
  853. moment.defaultZone = name ? getZone(name) : null;
  854. return moment;
  855. };
  856. // Cloning a moment should include the _z property.
  857. var momentProperties = moment.momentProperties;
  858. if (Object.prototype.toString.call(momentProperties) === '[object Array]') {
  859. // moment 2.8.1+
  860. momentProperties.push('_z');
  861. momentProperties.push('_a');
  862. } else if (momentProperties) {
  863. // moment 2.7.0
  864. momentProperties._z = null;
  865. }
  866. // INJECT DATA
  867. return moment;
  868. }));
  869. /***/ }),
  870. /***/ 6292:
  871. /***/ (function(module) {
  872. "use strict";
  873. module.exports = window["moment"];
  874. /***/ }),
  875. /***/ 1128:
  876. /***/ (function(module) {
  877. "use strict";
  878. module.exports = JSON.parse('{"version":"2022g","zones":["Africa/Abidjan|LMT GMT|g.8 0|01|-2ldXH.Q|48e5","Africa/Nairobi|LMT +0230 EAT +0245|-2r.g -2u -30 -2J|012132|-2ua2r.g N6nV.g 3Fbu h1cu dzbJ|47e5","Africa/Algiers|LMT PMT WET WEST CET CEST|-c.c -9.l 0 -10 -10 -20|01232323232323232454542423234542324|-3bQ0c.c MDA2.P cNb9.l HA0 19A0 1iM0 11c0 1oo0 Wo0 1rc0 QM0 1EM0 UM0 DA0 Imo0 rd0 De0 9Xz0 1fb0 1ap0 16K0 2yo0 mEp0 hwL0 jxA0 11A0 dDd0 17b0 11B0 1cN0 2Dy0 1cN0 1fB0 1cL0|26e5","Africa/Lagos|LMT GMT +0030 WAT|-d.z 0 -u -10|01023|-2B40d.z 7iod.z dnXK.p dLzH.z|17e6","Africa/Bissau|LMT -01 GMT|12.k 10 0|012|-2ldX0 2xoo0|39e4","Africa/Maputo|LMT CAT|-2a.k -20|01|-2GJea.k|26e5","Africa/Cairo|LMT EET EEST|-25.9 -20 -30|01212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121|-2MBC5.9 1AQM5.9 vb0 1ip0 11z0 1iN0 1nz0 12p0 1pz0 10N0 1pz0 16p0 1jz0 s3d0 Vz0 1oN0 11b0 1oO0 10N0 1pz0 10N0 1pb0 10N0 1pb0 10N0 1pb0 10N0 1pz0 10N0 1pb0 10N0 1pb0 11d0 1oL0 11d0 1pb0 11d0 1oL0 11d0 1oL0 11d0 1oL0 11d0 1pb0 11d0 1oL0 11d0 1oL0 11d0 1oL0 11d0 1pb0 11d0 1oL0 11d0 1oL0 11d0 1oL0 11d0 1pb0 11d0 1oL0 11d0 1WL0 rd0 1Rz0 wp0 1pb0 11d0 1oL0 11d0 1oL0 11d0 1oL0 11d0 1pb0 11d0 1qL0 Xd0 1oL0 11d0 1oL0 11d0 1pb0 11d0 1oL0 11d0 1oL0 11d0 1ny0 11z0 1o10 11z0 1o10 11z0 1o10 11z0 1qN0 11z0 1o10 11z0 1o10 11z0 1o10 11z0 1o10 11z0 1qN0 11z0 1o10 11z0 1o10 WL0 1qN0 Rb0 1wp0 On0 1zd0 Lz0 1EN0 Fb0 c10 8n0 8Nd0 gL0 e10 mn0|15e6","Africa/Casablanca|LMT +00 +01|u.k 0 -10|01212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212|-2gMnt.E 130Lt.E rb0 Dd0 dVb0 b6p0 TX0 EoB0 LL0 gnd0 rz0 43d0 AL0 1Nd0 XX0 1Cp0 pz0 dEp0 4mn0 SyN0 AL0 1Nd0 wn0 1FB0 Db0 1zd0 Lz0 1Nf0 wM0 co0 go0 1o00 s00 dA0 vc0 11A0 A00 e00 y00 11A0 uM0 e00 Dc0 11A0 s00 e00 IM0 WM0 mo0 gM0 LA0 WM0 jA0 e00 28M0 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 e00 28M0 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0 2600 gM0 2600 e00 2600 gM0|32e5","Africa/Ceuta|LMT WET WEST CET CEST|l.g 0 -10 -10 -20|0121212121212121212121343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343|-2M0M0 GdX0 11z0 drd0 18p0 3HX0 17d0 1fz0 1a10 1io0 1a00 1y7o0 LL0 gnd0 rz0 43d0 AL0 1Nd0 XX0 1Cp0 pz0 dEp0 4VB0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1fA0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1fA0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o
  879. /***/ })
  880. /******/ });
  881. /************************************************************************/
  882. /******/ // The module cache
  883. /******/ var __webpack_module_cache__ = {};
  884. /******/
  885. /******/ // The require function
  886. /******/ function __webpack_require__(moduleId) {
  887. /******/ // Check if module is in cache
  888. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  889. /******/ if (cachedModule !== undefined) {
  890. /******/ return cachedModule.exports;
  891. /******/ }
  892. /******/ // Create a new module (and put it into the cache)
  893. /******/ var module = __webpack_module_cache__[moduleId] = {
  894. /******/ // no module.id needed
  895. /******/ // no module.loaded needed
  896. /******/ exports: {}
  897. /******/ };
  898. /******/
  899. /******/ // Execute the module function
  900. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  901. /******/
  902. /******/ // Return the exports of the module
  903. /******/ return module.exports;
  904. /******/ }
  905. /******/
  906. /************************************************************************/
  907. /******/ /* webpack/runtime/compat get default export */
  908. /******/ !function() {
  909. /******/ // getDefaultExport function for compatibility with non-harmony modules
  910. /******/ __webpack_require__.n = function(module) {
  911. /******/ var getter = module && module.__esModule ?
  912. /******/ function() { return module['default']; } :
  913. /******/ function() { return module; };
  914. /******/ __webpack_require__.d(getter, { a: getter });
  915. /******/ return getter;
  916. /******/ };
  917. /******/ }();
  918. /******/
  919. /******/ /* webpack/runtime/define property getters */
  920. /******/ !function() {
  921. /******/ // define getter functions for harmony exports
  922. /******/ __webpack_require__.d = function(exports, definition) {
  923. /******/ for(var key in definition) {
  924. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  925. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  926. /******/ }
  927. /******/ }
  928. /******/ };
  929. /******/ }();
  930. /******/
  931. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  932. /******/ !function() {
  933. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  934. /******/ }();
  935. /******/
  936. /******/ /* webpack/runtime/make namespace object */
  937. /******/ !function() {
  938. /******/ // define __esModule on exports
  939. /******/ __webpack_require__.r = function(exports) {
  940. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  941. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  942. /******/ }
  943. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  944. /******/ };
  945. /******/ }();
  946. /******/
  947. /************************************************************************/
  948. var __webpack_exports__ = {};
  949. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  950. !function() {
  951. "use strict";
  952. // ESM COMPAT FLAG
  953. __webpack_require__.r(__webpack_exports__);
  954. // EXPORTS
  955. __webpack_require__.d(__webpack_exports__, {
  956. __experimentalGetSettings: function() { return /* binding */ __experimentalGetSettings; },
  957. date: function() { return /* binding */ date; },
  958. dateI18n: function() { return /* binding */ dateI18n; },
  959. format: function() { return /* binding */ format; },
  960. getDate: function() { return /* binding */ getDate; },
  961. getSettings: function() { return /* binding */ getSettings; },
  962. gmdate: function() { return /* binding */ gmdate; },
  963. gmdateI18n: function() { return /* binding */ gmdateI18n; },
  964. humanTimeDiff: function() { return /* binding */ humanTimeDiff; },
  965. isInTheFuture: function() { return /* binding */ isInTheFuture; },
  966. setSettings: function() { return /* binding */ setSettings; }
  967. });
  968. // EXTERNAL MODULE: external "moment"
  969. var external_moment_ = __webpack_require__(6292);
  970. var external_moment_default = /*#__PURE__*/__webpack_require__.n(external_moment_);
  971. // EXTERNAL MODULE: ./node_modules/moment-timezone/moment-timezone.js
  972. var moment_timezone = __webpack_require__(2828);
  973. // EXTERNAL MODULE: ./node_modules/moment-timezone/moment-timezone-utils.js
  974. var moment_timezone_utils = __webpack_require__(9971);
  975. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  976. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  977. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  978. ;// CONCATENATED MODULE: ./node_modules/@wordpress/date/build-module/index.js
  979. /**
  980. * External dependencies
  981. */
  982. /**
  983. * WordPress dependencies
  984. */
  985. /** @typedef {import('moment').Moment} Moment */
  986. /** @typedef {import('moment').LocaleSpecification} MomentLocaleSpecification */
  987. /**
  988. * @typedef MeridiemConfig
  989. * @property {string} am Lowercase AM.
  990. * @property {string} AM Uppercase AM.
  991. * @property {string} pm Lowercase PM.
  992. * @property {string} PM Uppercase PM.
  993. */
  994. /**
  995. * @typedef FormatsConfig
  996. * @property {string} time Time format.
  997. * @property {string} date Date format.
  998. * @property {string} datetime Datetime format.
  999. * @property {string} datetimeAbbreviated Abbreviated datetime format.
  1000. */
  1001. /**
  1002. * @typedef TimezoneConfig
  1003. * @property {string} offset Offset setting.
  1004. * @property {string} string The timezone as a string (e.g., `'America/Los_Angeles'`).
  1005. * @property {string} abbr Abbreviation for the timezone.
  1006. */
  1007. /* eslint-disable jsdoc/valid-types */
  1008. /**
  1009. * @typedef L10nSettings
  1010. * @property {string} locale Moment locale.
  1011. * @property {MomentLocaleSpecification['months']} months Locale months.
  1012. * @property {MomentLocaleSpecification['monthsShort']} monthsShort Locale months short.
  1013. * @property {MomentLocaleSpecification['weekdays']} weekdays Locale weekdays.
  1014. * @property {MomentLocaleSpecification['weekdaysShort']} weekdaysShort Locale weekdays short.
  1015. * @property {MeridiemConfig} meridiem Meridiem config.
  1016. * @property {MomentLocaleSpecification['relativeTime']} relative Relative time config.
  1017. * @property {0|1|2|3|4|5|6} startOfWeek Day that the week starts on.
  1018. */
  1019. /* eslint-enable jsdoc/valid-types */
  1020. /**
  1021. * @typedef DateSettings
  1022. * @property {L10nSettings} l10n Localization settings.
  1023. * @property {FormatsConfig} formats Date/time formats config.
  1024. * @property {TimezoneConfig} timezone Timezone settings.
  1025. */
  1026. const WP_ZONE = 'WP';
  1027. // This regular expression tests positive for UTC offsets as described in ISO 8601.
  1028. // See: https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
  1029. const VALID_UTC_OFFSET = /^[+-][0-1][0-9](:?[0-9][0-9])?$/;
  1030. // Changes made here will likely need to be made in `lib/client-assets.php` as
  1031. // well because it uses the `setSettings()` function to change these settings.
  1032. /** @type {DateSettings} */
  1033. let settings = {
  1034. l10n: {
  1035. locale: 'en',
  1036. months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  1037. monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  1038. weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  1039. weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  1040. meridiem: {
  1041. am: 'am',
  1042. pm: 'pm',
  1043. AM: 'AM',
  1044. PM: 'PM'
  1045. },
  1046. relative: {
  1047. future: '%s from now',
  1048. past: '%s ago',
  1049. s: 'a few seconds',
  1050. ss: '%d seconds',
  1051. m: 'a minute',
  1052. mm: '%d minutes',
  1053. h: 'an hour',
  1054. hh: '%d hours',
  1055. d: 'a day',
  1056. dd: '%d days',
  1057. M: 'a month',
  1058. MM: '%d months',
  1059. y: 'a year',
  1060. yy: '%d years'
  1061. },
  1062. startOfWeek: 0
  1063. },
  1064. formats: {
  1065. time: 'g: i a',
  1066. date: 'F j, Y',
  1067. datetime: 'F j, Y g: i a',
  1068. datetimeAbbreviated: 'M j, Y g: i a'
  1069. },
  1070. timezone: {
  1071. offset: '0',
  1072. string: '',
  1073. abbr: ''
  1074. }
  1075. };
  1076. /**
  1077. * Adds a locale to moment, using the format supplied by `wp_localize_script()`.
  1078. *
  1079. * @param {DateSettings} dateSettings Settings, including locale data.
  1080. */
  1081. function setSettings(dateSettings) {
  1082. settings = dateSettings;
  1083. setupWPTimezone();
  1084. // Does moment already have a locale with the right name?
  1085. if (external_moment_default().locales().includes(dateSettings.l10n.locale)) {
  1086. // Is that locale misconfigured, e.g. because we are on a site running
  1087. // WordPress < 6.0?
  1088. if (external_moment_default().localeData(dateSettings.l10n.locale).longDateFormat('LTS') === null) {
  1089. // Delete the misconfigured locale.
  1090. // @ts-ignore Type definitions are incorrect - null is permitted.
  1091. external_moment_default().defineLocale(dateSettings.l10n.locale, null);
  1092. } else {
  1093. // We have a properly configured locale, so no need to create one.
  1094. return;
  1095. }
  1096. }
  1097. // defineLocale() will modify the current locale, so back it up.
  1098. const currentLocale = external_moment_default().locale();
  1099. // Create locale.
  1100. external_moment_default().defineLocale(dateSettings.l10n.locale, {
  1101. // Inherit anything missing from English. We don't load
  1102. // moment-with-locales.js so English is all there is.
  1103. parentLocale: 'en',
  1104. months: dateSettings.l10n.months,
  1105. monthsShort: dateSettings.l10n.monthsShort,
  1106. weekdays: dateSettings.l10n.weekdays,
  1107. weekdaysShort: dateSettings.l10n.weekdaysShort,
  1108. meridiem(hour, minute, isLowercase) {
  1109. if (hour < 12) {
  1110. return isLowercase ? dateSettings.l10n.meridiem.am : dateSettings.l10n.meridiem.AM;
  1111. }
  1112. return isLowercase ? dateSettings.l10n.meridiem.pm : dateSettings.l10n.meridiem.PM;
  1113. },
  1114. longDateFormat: {
  1115. LT: dateSettings.formats.time,
  1116. LTS: external_moment_default().localeData('en').longDateFormat('LTS'),
  1117. L: external_moment_default().localeData('en').longDateFormat('L'),
  1118. LL: dateSettings.formats.date,
  1119. LLL: dateSettings.formats.datetime,
  1120. LLLL: external_moment_default().localeData('en').longDateFormat('LLLL')
  1121. },
  1122. // From human_time_diff?
  1123. // Set to `(number, withoutSuffix, key, isFuture) => {}` instead.
  1124. relativeTime: dateSettings.l10n.relative
  1125. });
  1126. // Restore the locale to what it was.
  1127. external_moment_default().locale(currentLocale);
  1128. }
  1129. /**
  1130. * Returns the currently defined date settings.
  1131. *
  1132. * @return {DateSettings} Settings, including locale data.
  1133. */
  1134. function getSettings() {
  1135. return settings;
  1136. }
  1137. /**
  1138. * Returns the currently defined date settings.
  1139. *
  1140. * @deprecated
  1141. * @return {DateSettings} Settings, including locale data.
  1142. */
  1143. function __experimentalGetSettings() {
  1144. external_wp_deprecated_default()('wp.date.__experimentalGetSettings', {
  1145. since: '6.1',
  1146. alternative: 'wp.date.getSettings'
  1147. });
  1148. return getSettings();
  1149. }
  1150. function setupWPTimezone() {
  1151. // Get the current timezone settings from the WP timezone string.
  1152. const currentTimezone = external_moment_default().tz.zone(settings.timezone.string);
  1153. // 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.
  1154. if (currentTimezone) {
  1155. // Create WP timezone based off settings.timezone.string. We need to include the additional data so that we
  1156. // don't lose information about daylight savings time and other items.
  1157. // See https://github.com/WordPress/gutenberg/pull/48083
  1158. external_moment_default().tz.add(external_moment_default().tz.pack({
  1159. name: WP_ZONE,
  1160. abbrs: currentTimezone.abbrs,
  1161. untils: currentTimezone.untils,
  1162. offsets: currentTimezone.offsets
  1163. }));
  1164. } else {
  1165. // Create WP timezone based off dateSettings.
  1166. external_moment_default().tz.add(external_moment_default().tz.pack({
  1167. name: WP_ZONE,
  1168. abbrs: [WP_ZONE],
  1169. untils: [null],
  1170. offsets: [-settings.timezone.offset * 60 || 0]
  1171. }));
  1172. }
  1173. }
  1174. // Date constants.
  1175. /**
  1176. * Number of seconds in one minute.
  1177. *
  1178. * @type {number}
  1179. */
  1180. const MINUTE_IN_SECONDS = 60;
  1181. /**
  1182. * Number of minutes in one hour.
  1183. *
  1184. * @type {number}
  1185. */
  1186. const HOUR_IN_MINUTES = 60;
  1187. /**
  1188. * Number of seconds in one hour.
  1189. *
  1190. * @type {number}
  1191. */
  1192. const HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;
  1193. /**
  1194. * Map of PHP formats to Moment.js formats.
  1195. *
  1196. * These are used internally by {@link wp.date.format}, and are either
  1197. * a string representing the corresponding Moment.js format code, or a
  1198. * function which returns the formatted string.
  1199. *
  1200. * This should only be used through {@link wp.date.format}, not
  1201. * directly.
  1202. */
  1203. const formatMap = {
  1204. // Day.
  1205. d: 'DD',
  1206. D: 'ddd',
  1207. j: 'D',
  1208. l: 'dddd',
  1209. N: 'E',
  1210. /**
  1211. * Gets the ordinal suffix.
  1212. *
  1213. * @param {Moment} momentDate Moment instance.
  1214. *
  1215. * @return {string} Formatted date.
  1216. */
  1217. S(momentDate) {
  1218. // Do - D.
  1219. const num = momentDate.format('D');
  1220. const withOrdinal = momentDate.format('Do');
  1221. return withOrdinal.replace(num, '');
  1222. },
  1223. w: 'd',
  1224. /**
  1225. * Gets the day of the year (zero-indexed).
  1226. *
  1227. * @param {Moment} momentDate Moment instance.
  1228. *
  1229. * @return {string} Formatted date.
  1230. */
  1231. z(momentDate) {
  1232. // DDD - 1.
  1233. return (parseInt(momentDate.format('DDD'), 10) - 1).toString();
  1234. },
  1235. // Week.
  1236. W: 'W',
  1237. // Month.
  1238. F: 'MMMM',
  1239. m: 'MM',
  1240. M: 'MMM',
  1241. n: 'M',
  1242. /**
  1243. * Gets the days in the month.
  1244. *
  1245. * @param {Moment} momentDate Moment instance.
  1246. *
  1247. * @return {number} Formatted date.
  1248. */
  1249. t(momentDate) {
  1250. return momentDate.daysInMonth();
  1251. },
  1252. // Year.
  1253. /**
  1254. * Gets whether the current year is a leap year.
  1255. *
  1256. * @param {Moment} momentDate Moment instance.
  1257. *
  1258. * @return {string} Formatted date.
  1259. */
  1260. L(momentDate) {
  1261. return momentDate.isLeapYear() ? '1' : '0';
  1262. },
  1263. o: 'GGGG',
  1264. Y: 'YYYY',
  1265. y: 'YY',
  1266. // Time.
  1267. a: 'a',
  1268. A: 'A',
  1269. /**
  1270. * Gets the current time in Swatch Internet Time (.beats).
  1271. *
  1272. * @param {Moment} momentDate Moment instance.
  1273. *
  1274. * @return {number} Formatted date.
  1275. */
  1276. B(momentDate) {
  1277. const timezoned = external_moment_default()(momentDate).utcOffset(60);
  1278. const seconds = parseInt(timezoned.format('s'), 10),
  1279. minutes = parseInt(timezoned.format('m'), 10),
  1280. hours = parseInt(timezoned.format('H'), 10);
  1281. return parseInt(((seconds + minutes * MINUTE_IN_SECONDS + hours * HOUR_IN_SECONDS) / 86.4).toString(), 10);
  1282. },
  1283. g: 'h',
  1284. G: 'H',
  1285. h: 'hh',
  1286. H: 'HH',
  1287. i: 'mm',
  1288. s: 'ss',
  1289. u: 'SSSSSS',
  1290. v: 'SSS',
  1291. // Timezone.
  1292. e: 'zz',
  1293. /**
  1294. * Gets whether the timezone is in DST currently.
  1295. *
  1296. * @param {Moment} momentDate Moment instance.
  1297. *
  1298. * @return {string} Formatted date.
  1299. */
  1300. I(momentDate) {
  1301. return momentDate.isDST() ? '1' : '0';
  1302. },
  1303. O: 'ZZ',
  1304. P: 'Z',
  1305. T: 'z',
  1306. /**
  1307. * Gets the timezone offset in seconds.
  1308. *
  1309. * @param {Moment} momentDate Moment instance.
  1310. *
  1311. * @return {number} Formatted date.
  1312. */
  1313. Z(momentDate) {
  1314. // Timezone offset in seconds.
  1315. const offset = momentDate.format('Z');
  1316. const sign = offset[0] === '-' ? -1 : 1;
  1317. const parts = offset.substring(1).split(':').map(n => parseInt(n, 10));
  1318. return sign * (parts[0] * HOUR_IN_MINUTES + parts[1]) * MINUTE_IN_SECONDS;
  1319. },
  1320. // Full date/time.
  1321. c: 'YYYY-MM-DDTHH:mm:ssZ',
  1322. // .toISOString.
  1323. /**
  1324. * Formats the date as RFC2822.
  1325. *
  1326. * @param {Moment} momentDate Moment instance.
  1327. *
  1328. * @return {string} Formatted date.
  1329. */
  1330. r(momentDate) {
  1331. return momentDate.locale('en').format('ddd, DD MMM YYYY HH:mm:ss ZZ');
  1332. },
  1333. U: 'X'
  1334. };
  1335. /**
  1336. * Formats a date. Does not alter the date's timezone.
  1337. *
  1338. * @param {string} dateFormat PHP-style formatting string.
  1339. * See php.net/date.
  1340. * @param {Moment | Date | string | undefined} dateValue Date object or string,
  1341. * parsable by moment.js.
  1342. *
  1343. * @return {string} Formatted date.
  1344. */
  1345. function format(dateFormat, dateValue = new Date()) {
  1346. let i, char;
  1347. const newFormat = [];
  1348. const momentDate = external_moment_default()(dateValue);
  1349. for (i = 0; i < dateFormat.length; i++) {
  1350. char = dateFormat[i];
  1351. // Is this an escape?
  1352. if ('\\' === char) {
  1353. // Add next character, then move on.
  1354. i++;
  1355. newFormat.push('[' + dateFormat[i] + ']');
  1356. continue;
  1357. }
  1358. if (char in formatMap) {
  1359. const formatter = formatMap[/** @type {keyof formatMap} */char];
  1360. if (typeof formatter !== 'string') {
  1361. // If the format is a function, call it.
  1362. newFormat.push('[' + formatter(momentDate) + ']');
  1363. } else {
  1364. // Otherwise, add as a formatting string.
  1365. newFormat.push(formatter);
  1366. }
  1367. } else {
  1368. newFormat.push('[' + char + ']');
  1369. }
  1370. }
  1371. // Join with [] between to separate characters, and replace
  1372. // unneeded separators with static text.
  1373. return momentDate.format(newFormat.join('[]'));
  1374. }
  1375. /**
  1376. * Formats a date (like `date()` in PHP).
  1377. *
  1378. * @param {string} dateFormat PHP-style formatting string.
  1379. * See php.net/date.
  1380. * @param {Moment | Date | string | undefined} dateValue Date object or string, parsable
  1381. * by moment.js.
  1382. * @param {string | number | undefined} timezone Timezone to output result in or a
  1383. * UTC offset. Defaults to timezone from
  1384. * site.
  1385. *
  1386. * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  1387. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
  1388. *
  1389. * @return {string} Formatted date in English.
  1390. */
  1391. function date(dateFormat, dateValue = new Date(), timezone) {
  1392. const dateMoment = buildMoment(dateValue, timezone);
  1393. return format(dateFormat, dateMoment);
  1394. }
  1395. /**
  1396. * Formats a date (like `date()` in PHP), in the UTC timezone.
  1397. *
  1398. * @param {string} dateFormat PHP-style formatting string.
  1399. * See php.net/date.
  1400. * @param {Moment | Date | string | undefined} dateValue Date object or string,
  1401. * parsable by moment.js.
  1402. *
  1403. * @return {string} Formatted date in English.
  1404. */
  1405. function gmdate(dateFormat, dateValue = new Date()) {
  1406. const dateMoment = external_moment_default()(dateValue).utc();
  1407. return format(dateFormat, dateMoment);
  1408. }
  1409. /**
  1410. * Formats a date (like `wp_date()` in PHP), translating it into site's locale.
  1411. *
  1412. * Backward Compatibility Notice: if `timezone` is set to `true`, the function
  1413. * behaves like `gmdateI18n`.
  1414. *
  1415. * @param {string} dateFormat PHP-style formatting string.
  1416. * See php.net/date.
  1417. * @param {Moment | Date | string | undefined} dateValue Date object or string, parsable by
  1418. * moment.js.
  1419. * @param {string | number | boolean | undefined} timezone Timezone to output result in or a
  1420. * UTC offset. Defaults to timezone from
  1421. * site. Notice: `boolean` is effectively
  1422. * deprecated, but still supported for
  1423. * backward compatibility reasons.
  1424. *
  1425. * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  1426. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
  1427. *
  1428. * @return {string} Formatted date.
  1429. */
  1430. function dateI18n(dateFormat, dateValue = new Date(), timezone) {
  1431. if (true === timezone) {
  1432. return gmdateI18n(dateFormat, dateValue);
  1433. }
  1434. if (false === timezone) {
  1435. timezone = undefined;
  1436. }
  1437. const dateMoment = buildMoment(dateValue, timezone);
  1438. dateMoment.locale(settings.l10n.locale);
  1439. return format(dateFormat, dateMoment);
  1440. }
  1441. /**
  1442. * Formats a date (like `wp_date()` in PHP), translating it into site's locale
  1443. * and using the UTC timezone.
  1444. *
  1445. * @param {string} dateFormat PHP-style formatting string.
  1446. * See php.net/date.
  1447. * @param {Moment | Date | string | undefined} dateValue Date object or string,
  1448. * parsable by moment.js.
  1449. *
  1450. * @return {string} Formatted date.
  1451. */
  1452. function gmdateI18n(dateFormat, dateValue = new Date()) {
  1453. const dateMoment = external_moment_default()(dateValue).utc();
  1454. dateMoment.locale(settings.l10n.locale);
  1455. return format(dateFormat, dateMoment);
  1456. }
  1457. /**
  1458. * Check whether a date is considered in the future according to the WordPress settings.
  1459. *
  1460. * @param {string} dateValue Date String or Date object in the Defined WP Timezone.
  1461. *
  1462. * @return {boolean} Is in the future.
  1463. */
  1464. function isInTheFuture(dateValue) {
  1465. const now = external_moment_default().tz(WP_ZONE);
  1466. const momentObject = external_moment_default().tz(dateValue, WP_ZONE);
  1467. return momentObject.isAfter(now);
  1468. }
  1469. /**
  1470. * Create and return a JavaScript Date Object from a date string in the WP timezone.
  1471. *
  1472. * @param {string?} dateString Date formatted in the WP timezone.
  1473. *
  1474. * @return {Date} Date
  1475. */
  1476. function getDate(dateString) {
  1477. if (!dateString) {
  1478. return external_moment_default().tz(WP_ZONE).toDate();
  1479. }
  1480. return external_moment_default().tz(dateString, WP_ZONE).toDate();
  1481. }
  1482. /**
  1483. * Returns a human-readable time difference between two dates, like human_time_diff() in PHP.
  1484. *
  1485. * @param {Moment | Date | string} from From date, in the WP timezone.
  1486. * @param {Moment | Date | string | undefined} to To date, formatted in the WP timezone.
  1487. *
  1488. * @return {string} Human-readable time difference.
  1489. */
  1490. function humanTimeDiff(from, to) {
  1491. const fromMoment = external_moment_default().tz(from, WP_ZONE);
  1492. const toMoment = to ? external_moment_default().tz(to, WP_ZONE) : external_moment_default().tz(WP_ZONE);
  1493. return fromMoment.from(toMoment);
  1494. }
  1495. /**
  1496. * Creates a moment instance using the given timezone or, if none is provided, using global settings.
  1497. *
  1498. * @param {Moment | Date | string | undefined} dateValue Date object or string, parsable
  1499. * by moment.js.
  1500. * @param {string | number | undefined} timezone Timezone to output result in or a
  1501. * UTC offset. Defaults to timezone from
  1502. * site.
  1503. *
  1504. * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  1505. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
  1506. *
  1507. * @return {Moment} a moment instance.
  1508. */
  1509. function buildMoment(dateValue, timezone = '') {
  1510. const dateMoment = external_moment_default()(dateValue);
  1511. if (timezone && !isUTCOffset(timezone)) {
  1512. // The ! isUTCOffset() check guarantees that timezone is a string.
  1513. return dateMoment.tz( /** @type {string} */timezone);
  1514. }
  1515. if (timezone && isUTCOffset(timezone)) {
  1516. return dateMoment.utcOffset(timezone);
  1517. }
  1518. if (settings.timezone.string) {
  1519. return dateMoment.tz(settings.timezone.string);
  1520. }
  1521. return dateMoment.utcOffset(+settings.timezone.offset);
  1522. }
  1523. /**
  1524. * Returns whether a certain UTC offset is valid or not.
  1525. *
  1526. * @param {number|string} offset a UTC offset.
  1527. *
  1528. * @return {boolean} whether a certain UTC offset is valid or not.
  1529. */
  1530. function isUTCOffset(offset) {
  1531. if ('number' === typeof offset) {
  1532. return true;
  1533. }
  1534. return VALID_UTC_OFFSET.test(offset);
  1535. }
  1536. setupWPTimezone();
  1537. }();
  1538. (window.wp = window.wp || {}).date = __webpack_exports__;
  1539. /******/ })()
  1540. ;