@wix/design-systems-locale-utils 1.181.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.
Files changed (99) hide show
  1. package/README.md +57 -0
  2. package/dist/cjs/constants.js +6 -0
  3. package/dist/cjs/constants.js.map +1 -0
  4. package/dist/cjs/dateTimeFormat/dateTimeFormat.js +19 -0
  5. package/dist/cjs/dateTimeFormat/dateTimeFormat.js.map +1 -0
  6. package/dist/cjs/dateTimeFormat/getLongDate/getLongDate.js +19 -0
  7. package/dist/cjs/dateTimeFormat/getLongDate/getLongDate.js.map +1 -0
  8. package/dist/cjs/dateTimeFormat/getLongDate/getLongDate.spec.js +20 -0
  9. package/dist/cjs/dateTimeFormat/getLongDate/getLongDate.spec.js.map +1 -0
  10. package/dist/cjs/dateTimeFormat/getLongTime/getLongTime.js +30 -0
  11. package/dist/cjs/dateTimeFormat/getLongTime/getLongTime.js.map +1 -0
  12. package/dist/cjs/dateTimeFormat/getLongTime/getLongTime.spec.js +14 -0
  13. package/dist/cjs/dateTimeFormat/getLongTime/getLongTime.spec.js.map +1 -0
  14. package/dist/cjs/dateTimeFormat/getMediumDate/getMediumDate.js +16 -0
  15. package/dist/cjs/dateTimeFormat/getMediumDate/getMediumDate.js.map +1 -0
  16. package/dist/cjs/dateTimeFormat/getMediumDate/getMediumDate.spec.js +9 -0
  17. package/dist/cjs/dateTimeFormat/getMediumDate/getMediumDate.spec.js.map +1 -0
  18. package/dist/cjs/dateTimeFormat/getShortDate/getShortDate.js +80 -0
  19. package/dist/cjs/dateTimeFormat/getShortDate/getShortDate.js.map +1 -0
  20. package/dist/cjs/dateTimeFormat/getShortDate/getShortDate.spec.js +29 -0
  21. package/dist/cjs/dateTimeFormat/getShortDate/getShortDate.spec.js.map +1 -0
  22. package/dist/cjs/dateTimeFormat/getShortTime/getShortTime.js +30 -0
  23. package/dist/cjs/dateTimeFormat/getShortTime/getShortTime.js.map +1 -0
  24. package/dist/cjs/dateTimeFormat/getShortTime/getShortTime.spec.js +14 -0
  25. package/dist/cjs/dateTimeFormat/getShortTime/getShortTime.spec.js.map +1 -0
  26. package/dist/cjs/dateTimeFormat/getYear/getYear.js +18 -0
  27. package/dist/cjs/dateTimeFormat/getYear/getYear.js.map +1 -0
  28. package/dist/cjs/dateTimeFormat/getYear/getYear.spec.js +54 -0
  29. package/dist/cjs/dateTimeFormat/getYear/getYear.spec.js.map +1 -0
  30. package/dist/cjs/dateTimeFormat/index.js +7 -0
  31. package/dist/cjs/dateTimeFormat/index.js.map +1 -0
  32. package/dist/cjs/index.js +17 -0
  33. package/dist/cjs/index.js.map +1 -0
  34. package/dist/esm/constants.js +57 -0
  35. package/dist/esm/constants.js.map +1 -0
  36. package/dist/esm/dateTimeFormat/dateTimeFormat.js +15 -0
  37. package/dist/esm/dateTimeFormat/dateTimeFormat.js.map +1 -0
  38. package/dist/esm/dateTimeFormat/getLongDate/getLongDate.js +14 -0
  39. package/dist/esm/dateTimeFormat/getLongDate/getLongDate.js.map +1 -0
  40. package/dist/esm/dateTimeFormat/getLongDate/getLongDate.spec.js +15 -0
  41. package/dist/esm/dateTimeFormat/getLongDate/getLongDate.spec.js.map +1 -0
  42. package/dist/esm/dateTimeFormat/getLongTime/getLongTime.js +23 -0
  43. package/dist/esm/dateTimeFormat/getLongTime/getLongTime.js.map +1 -0
  44. package/dist/esm/dateTimeFormat/getLongTime/getLongTime.spec.js +12 -0
  45. package/dist/esm/dateTimeFormat/getLongTime/getLongTime.spec.js.map +1 -0
  46. package/dist/esm/dateTimeFormat/getMediumDate/getMediumDate.js +9 -0
  47. package/dist/esm/dateTimeFormat/getMediumDate/getMediumDate.js.map +1 -0
  48. package/dist/esm/dateTimeFormat/getMediumDate/getMediumDate.spec.js +7 -0
  49. package/dist/esm/dateTimeFormat/getMediumDate/getMediumDate.spec.js.map +1 -0
  50. package/dist/esm/dateTimeFormat/getShortDate/getShortDate.js +47 -0
  51. package/dist/esm/dateTimeFormat/getShortDate/getShortDate.js.map +1 -0
  52. package/dist/esm/dateTimeFormat/getShortDate/getShortDate.spec.js +27 -0
  53. package/dist/esm/dateTimeFormat/getShortDate/getShortDate.spec.js.map +1 -0
  54. package/dist/esm/dateTimeFormat/getShortTime/getShortTime.js +23 -0
  55. package/dist/esm/dateTimeFormat/getShortTime/getShortTime.js.map +1 -0
  56. package/dist/esm/dateTimeFormat/getShortTime/getShortTime.spec.js +12 -0
  57. package/dist/esm/dateTimeFormat/getShortTime/getShortTime.spec.js.map +1 -0
  58. package/dist/esm/dateTimeFormat/getYear/getYear.js +12 -0
  59. package/dist/esm/dateTimeFormat/getYear/getYear.js.map +1 -0
  60. package/dist/esm/dateTimeFormat/getYear/getYear.spec.js +63 -0
  61. package/dist/esm/dateTimeFormat/getYear/getYear.spec.js.map +1 -0
  62. package/dist/esm/dateTimeFormat/index.js +2 -0
  63. package/dist/esm/dateTimeFormat/index.js.map +1 -0
  64. package/dist/esm/index.js +3 -0
  65. package/dist/esm/index.js.map +1 -0
  66. package/dist/tsconfig.tsbuildinfo +1 -0
  67. package/dist/types/constants.d.ts +3 -0
  68. package/dist/types/constants.d.ts.map +1 -0
  69. package/dist/types/dateTimeFormat/dateTimeFormat.d.ts +9 -0
  70. package/dist/types/dateTimeFormat/dateTimeFormat.d.ts.map +1 -0
  71. package/dist/types/dateTimeFormat/getLongDate/getLongDate.d.ts +8 -0
  72. package/dist/types/dateTimeFormat/getLongDate/getLongDate.d.ts.map +1 -0
  73. package/dist/types/dateTimeFormat/getLongDate/getLongDate.spec.d.ts +2 -0
  74. package/dist/types/dateTimeFormat/getLongDate/getLongDate.spec.d.ts.map +1 -0
  75. package/dist/types/dateTimeFormat/getLongTime/getLongTime.d.ts +8 -0
  76. package/dist/types/dateTimeFormat/getLongTime/getLongTime.d.ts.map +1 -0
  77. package/dist/types/dateTimeFormat/getLongTime/getLongTime.spec.d.ts +2 -0
  78. package/dist/types/dateTimeFormat/getLongTime/getLongTime.spec.d.ts.map +1 -0
  79. package/dist/types/dateTimeFormat/getMediumDate/getMediumDate.d.ts +8 -0
  80. package/dist/types/dateTimeFormat/getMediumDate/getMediumDate.d.ts.map +1 -0
  81. package/dist/types/dateTimeFormat/getMediumDate/getMediumDate.spec.d.ts +2 -0
  82. package/dist/types/dateTimeFormat/getMediumDate/getMediumDate.spec.d.ts.map +1 -0
  83. package/dist/types/dateTimeFormat/getShortDate/getShortDate.d.ts +8 -0
  84. package/dist/types/dateTimeFormat/getShortDate/getShortDate.d.ts.map +1 -0
  85. package/dist/types/dateTimeFormat/getShortDate/getShortDate.spec.d.ts +2 -0
  86. package/dist/types/dateTimeFormat/getShortDate/getShortDate.spec.d.ts.map +1 -0
  87. package/dist/types/dateTimeFormat/getShortTime/getShortTime.d.ts +8 -0
  88. package/dist/types/dateTimeFormat/getShortTime/getShortTime.d.ts.map +1 -0
  89. package/dist/types/dateTimeFormat/getShortTime/getShortTime.spec.d.ts +2 -0
  90. package/dist/types/dateTimeFormat/getShortTime/getShortTime.spec.d.ts.map +1 -0
  91. package/dist/types/dateTimeFormat/getYear/getYear.d.ts +8 -0
  92. package/dist/types/dateTimeFormat/getYear/getYear.d.ts.map +1 -0
  93. package/dist/types/dateTimeFormat/getYear/getYear.spec.d.ts +2 -0
  94. package/dist/types/dateTimeFormat/getYear/getYear.spec.d.ts.map +1 -0
  95. package/dist/types/dateTimeFormat/index.d.ts +2 -0
  96. package/dist/types/dateTimeFormat/index.d.ts.map +1 -0
  97. package/dist/types/index.d.ts +3 -0
  98. package/dist/types/index.d.ts.map +1 -0
  99. package/package.json +45 -0
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # @wix/design-systems-locale-utils
2
+
3
+ > A common utils used within the `wix-design-systems` packages
4
+
5
+ ## Locale utils
6
+
7
+ The following helper functions can be used within the different `wix-design-systems` packages:
8
+
9
+ ### `getShortDate`
10
+
11
+ returns short date format approved by Wix Localization team
12
+
13
+ ```javascript
14
+ import { dateTimeFormat } from '@wix/design-systems-locale-utils';
15
+
16
+ const date = dateTimeFormat.getShortDate('lt', new Date('2021/08/13')); //"2021-08-13"
17
+ ```
18
+
19
+ ### `getMediumDate`
20
+
21
+ returns medium date format approved by Wix Localization team
22
+
23
+ ```javascript
24
+ import { dateTimeFormat } from '@wix/design-systems-locale-utils';
25
+
26
+ const date = dateTimeFormat.getMediumDate('tr', new Date('2021/08/13')); //"21 Tem 2021"
27
+ ```
28
+
29
+ ### `getShortTime`
30
+
31
+ returns short time format approved by Wix Localization team
32
+
33
+ ```javascript
34
+ import { dateTimeFormat } from '@wix/design-systems-locale-utils';
35
+
36
+ const time = dateTimeFormat.getShortTime('lt', new Date('2021/08/12 16:45')); //"16:45"
37
+ ```
38
+
39
+ ### `getLongTime`
40
+
41
+ returns long time format approved by Wix Localization team
42
+
43
+ ```javascript
44
+ import { dateTimeFormat } from '@wix/design-systems-locale-utils';
45
+
46
+ const time = dateTimeFormat.getLongTime('tr', new Date('2021/08/12 16:45')); //"ÖS 4:45 GMT+3"
47
+ ```
48
+
49
+ ### `getYear`
50
+
51
+ returns formatted year
52
+
53
+ ```javascript
54
+ import { dateTimeFormat } from '@wix/design-systems-locale-utils';
55
+
56
+ const time = dateTimeFormat.getYear('ko', new Date('2022')); // "2022년"
57
+ ```
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.SupportedWixLocales = void 0;
5
+ const SupportedWixLocales = exports.SupportedWixLocales = ['en', 'en-US', 'en-GB', 'en-AU', 'en-CA', 'ar', 'bg', 'ca', 'zh', 'zh-TW', 'zh-HK', 'zh-MO', 'cs', 'da', 'nl', 'fi', 'fr', 'fr-CA', 'fr-CH', 'fr-BE', 'de', 'de-CH', 'de-AT', 'el', 'he', 'hi', 'hu', 'id', 'it', 'ja', 'ko', 'lt', 'ms', 'no', 'nb', 'nn', 'pl', 'pt-BR', 'pt', 'ro', 'ru', 'sk', 'sl', 'es', 'es-419', 'es-AR', 'es-MX', 'es-US', 'sv', 'tl', 'th', 'tr', 'uk', 'vi'];
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SupportedWixLocales","exports"],"sources":["../../src/constants.ts"],"sourcesContent":["export const SupportedWixLocales = [\n 'en',\n 'en-US',\n 'en-GB',\n 'en-AU',\n 'en-CA',\n 'ar',\n 'bg',\n 'ca',\n 'zh',\n 'zh-TW',\n 'zh-HK',\n 'zh-MO',\n 'cs',\n 'da',\n 'nl',\n 'fi',\n 'fr',\n 'fr-CA',\n 'fr-CH',\n 'fr-BE',\n 'de',\n 'de-CH',\n 'de-AT',\n 'el',\n 'he',\n 'hi',\n 'hu',\n 'id',\n 'it',\n 'ja',\n 'ko',\n 'lt',\n 'ms',\n 'no',\n 'nb',\n 'nn',\n 'pl',\n 'pt-BR',\n 'pt',\n 'ro',\n 'ru',\n 'sk',\n 'sl',\n 'es',\n 'es-419',\n 'es-AR',\n 'es-MX',\n 'es-US',\n 'sv',\n 'tl',\n 'th',\n 'tr',\n 'uk',\n 'vi',\n] as const;\n\nexport type SupportedWixLocales = typeof SupportedWixLocales[number];\n"],"mappings":";;;;AAAO,MAAMA,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,CACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,OAAO,EACP,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,CACI","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.dateTimeFormat = void 0;
5
+ var _getYear = require("./getYear/getYear");
6
+ var _getMediumDate = require("./getMediumDate/getMediumDate");
7
+ var _getLongDate = require("./getLongDate/getLongDate");
8
+ var _getLongTime = require("./getLongTime/getLongTime");
9
+ var _getShortDate = require("./getShortDate/getShortDate");
10
+ var _getShortTime = require("./getShortTime/getShortTime");
11
+ const dateTimeFormat = exports.dateTimeFormat = {
12
+ getShortDate: _getShortDate.getShortDate,
13
+ getMediumDate: _getMediumDate.getMediumDate,
14
+ getLongDate: _getLongDate.getLongDate,
15
+ getShortTime: _getShortTime.getShortTime,
16
+ getLongTime: _getLongTime.getLongTime,
17
+ getYear: _getYear.getYear
18
+ };
19
+ //# sourceMappingURL=dateTimeFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getYear","require","_getMediumDate","_getLongDate","_getLongTime","_getShortDate","_getShortTime","dateTimeFormat","exports","getShortDate","getMediumDate","getLongDate","getShortTime","getLongTime","getYear"],"sources":["../../../src/dateTimeFormat/dateTimeFormat.ts"],"sourcesContent":["import { getYear } from './getYear/getYear';\nimport { getMediumDate } from './getMediumDate/getMediumDate';\nimport { getLongDate } from './getLongDate/getLongDate';\nimport { getLongTime } from './getLongTime/getLongTime';\nimport { getShortDate } from './getShortDate/getShortDate';\nimport { getShortTime } from './getShortTime/getShortTime';\n\nexport const dateTimeFormat = {\n getShortDate,\n getMediumDate,\n getLongDate,\n getShortTime,\n getLongTime,\n getYear,\n};\n"],"mappings":";;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAEO,MAAMM,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC5BE,YAAY,EAAZA,0BAAY;EACZC,aAAa,EAAbA,4BAAa;EACbC,WAAW,EAAXA,wBAAW;EACXC,YAAY,EAAZA,0BAAY;EACZC,WAAW,EAAXA,wBAAW;EACXC,OAAO,EAAPA;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getLongDate = void 0;
5
+ /**
6
+ * Function that returns long date format approved by Wix Localization team.
7
+ * @param locale - language/country short value that is passed to Intl.DateTimeFormat
8
+ * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.
9
+ */
10
+ const getLongDate = (locale, date) => {
11
+ return new Intl.DateTimeFormat(locale, {
12
+ weekday: 'short',
13
+ year: 'numeric',
14
+ month: 'short',
15
+ day: 'numeric'
16
+ }).format(date);
17
+ };
18
+ exports.getLongDate = getLongDate;
19
+ //# sourceMappingURL=getLongDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getLongDate","locale","date","Intl","DateTimeFormat","weekday","year","month","day","format","exports"],"sources":["../../../../src/dateTimeFormat/getLongDate/getLongDate.ts"],"sourcesContent":["import { SupportedWixLocales } from '../../constants';\n\n/**\n * Function that returns long date format approved by Wix Localization team.\n * @param locale - language/country short value that is passed to Intl.DateTimeFormat\n * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.\n */\nexport const getLongDate = (locale: SupportedWixLocales, date: Date) => {\n return new Intl.DateTimeFormat(locale, {\n weekday: 'short',\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n }).format(date);\n};\n"],"mappings":";;;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAGA,CAACC,MAA2B,EAAEC,IAAU,KAAK;EACtE,OAAO,IAAIC,IAAI,CAACC,cAAc,CAACH,MAAM,EAAE;IACrCI,OAAO,EAAE,OAAO;IAChBC,IAAI,EAAE,SAAS;IACfC,KAAK,EAAE,OAAO;IACdC,GAAG,EAAE;EACP,CAAC,CAAC,CAACC,MAAM,CAACP,IAAI,CAAC;AACjB,CAAC;AAACQ,OAAA,CAAAV,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _getLongDate = require("./getLongDate");
4
+ describe('getLongDate', () => {
5
+ it.each`
6
+ locale | expected
7
+ ${'en-US'} | ${'Thu, Aug 12, 2021'}
8
+ ${'en-GB'} | ${'Thu, 12 Aug 2021'}
9
+ ${'nl'} | ${'do 12 aug 2021'}
10
+ ${'fr'} | ${'jeu. 12 août 2021'}
11
+ ${'de'} | ${'Do., 12. Aug. 2021'}
12
+ ${'it'} | ${'gio 12 ago 2021'}
13
+ `('should return correct long date based on $locale', ({
14
+ locale,
15
+ expected
16
+ }) => {
17
+ expect((0, _getLongDate.getLongDate)(locale, new Date('2021-08-12'))).toBe(expected);
18
+ });
19
+ });
20
+ //# sourceMappingURL=getLongDate.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getLongDate","require","describe","it","each","locale","expected","expect","getLongDate","Date","toBe"],"sources":["../../../../src/dateTimeFormat/getLongDate/getLongDate.spec.ts"],"sourcesContent":["import { getLongDate } from './getLongDate';\n\ndescribe('getLongDate', () => {\n it.each`\n locale | expected\n ${'en-US'} | ${'Thu, Aug 12, 2021'}\n ${'en-GB'} | ${'Thu, 12 Aug 2021'}\n ${'nl'} | ${'do 12 aug 2021'}\n ${'fr'} | ${'jeu. 12 août 2021'}\n ${'de'} | ${'Do., 12. Aug. 2021'}\n ${'it'} | ${'gio 12 ago 2021'}\n `(\n 'should return correct long date based on $locale',\n ({ locale, expected }) => {\n expect(getLongDate(locale, new Date('2021-08-12'))).toBe(expected);\n },\n );\n});\n"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC5BC,EAAE,CAACC,IAAI;AACT;AACA,MAAM,OAAO,MAAM,mBAAmB;AACtC,MAAM,OAAO,MAAM,kBAAkB;AACrC,MAAM,IAAI,SAAS,gBAAgB;AACnC,MAAM,IAAI,SAAS,mBAAmB;AACtC,MAAM,IAAI,SAAS,oBAAoB;AACvC,MAAM,IAAI,SAAS,iBAAiB;AACpC,GAAG,CACC,kDAAkD,EAClD,CAAC;IAAEC,MAAM;IAAEC;EAAS,CAAC,KAAK;IACxBC,MAAM,CAAC,IAAAC,wBAAW,EAACH,MAAM,EAAE,IAAII,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAACJ,QAAQ,CAAC;EACpE,CACF,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getLongTime = void 0;
5
+ const longTimeOptions = {
6
+ hour: 'numeric',
7
+ minute: 'numeric',
8
+ timeZoneName: 'short'
9
+ };
10
+ const modifiedLongTimes = {
11
+ tr: date => new Intl.DateTimeFormat('tr', {
12
+ ...longTimeOptions,
13
+ hour12: true
14
+ }).format(date)
15
+ };
16
+
17
+ /**
18
+ * Function that returns long time format approved by Wix Localization team.
19
+ * @param locale - language/country short value that is passed to Intl.DateTimeFormat
20
+ * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.
21
+ */
22
+ const getLongTime = (locale, date) => {
23
+ if (modifiedLongTimes[locale]) {
24
+ var _modifiedLongTimes$lo;
25
+ return (_modifiedLongTimes$lo = modifiedLongTimes[locale]) == null ? void 0 : _modifiedLongTimes$lo.call(modifiedLongTimes, date);
26
+ }
27
+ return new Intl.DateTimeFormat(locale, longTimeOptions).format(date);
28
+ };
29
+ exports.getLongTime = getLongTime;
30
+ //# sourceMappingURL=getLongTime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["longTimeOptions","hour","minute","timeZoneName","modifiedLongTimes","tr","date","Intl","DateTimeFormat","hour12","format","getLongTime","locale","_modifiedLongTimes$lo","call","exports"],"sources":["../../../../src/dateTimeFormat/getLongTime/getLongTime.ts"],"sourcesContent":["import { SupportedWixLocales } from '../../constants';\n\nconst longTimeOptions: {\n hour: '2-digit' | 'numeric';\n minute: '2-digit' | 'numeric';\n timeZoneName: 'short' | 'long';\n} = {\n hour: 'numeric',\n minute: 'numeric',\n timeZoneName: 'short',\n};\n\nconst modifiedLongTimes: Partial<\n Record<SupportedWixLocales, (date: Date) => string>\n> = {\n tr: (date: Date) =>\n new Intl.DateTimeFormat('tr', {\n ...longTimeOptions,\n hour12: true,\n }).format(date),\n} as const;\n\n/**\n * Function that returns long time format approved by Wix Localization team.\n * @param locale - language/country short value that is passed to Intl.DateTimeFormat\n * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.\n */\nexport const getLongTime = (locale: SupportedWixLocales, date: Date) => {\n if (modifiedLongTimes[locale]) {\n return modifiedLongTimes[locale]?.(date);\n }\n\n return new Intl.DateTimeFormat(locale, longTimeOptions).format(date);\n};\n"],"mappings":";;;;AAEA,MAAMA,eAIL,GAAG;EACFC,IAAI,EAAE,SAAS;EACfC,MAAM,EAAE,SAAS;EACjBC,YAAY,EAAE;AAChB,CAAC;AAED,MAAMC,iBAEL,GAAG;EACFC,EAAE,EAAGC,IAAU,IACb,IAAIC,IAAI,CAACC,cAAc,CAAC,IAAI,EAAE;IAC5B,GAAGR,eAAe;IAClBS,MAAM,EAAE;EACV,CAAC,CAAC,CAACC,MAAM,CAACJ,IAAI;AAClB,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACO,MAAMK,WAAW,GAAGA,CAACC,MAA2B,EAAEN,IAAU,KAAK;EACtE,IAAIF,iBAAiB,CAACQ,MAAM,CAAC,EAAE;IAAA,IAAAC,qBAAA;IAC7B,QAAAA,qBAAA,GAAOT,iBAAiB,CAACQ,MAAM,CAAC,qBAAzBC,qBAAA,CAAAC,IAAA,CAAAV,iBAAiB,EAAWE,IAAI,CAAC;EAC1C;EAEA,OAAO,IAAIC,IAAI,CAACC,cAAc,CAACI,MAAM,EAAEZ,eAAe,CAAC,CAACU,MAAM,CAACJ,IAAI,CAAC;AACtE,CAAC;AAACS,OAAA,CAAAJ,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _getLongTime = require("./getLongTime");
4
+ describe('getLongTime', () => {
5
+ it('to return long time generated by Intl', async () => {
6
+ expect((0, _getLongTime.getLongTime)('lt', new Date('2021-08-12 16:45'))).toMatch(/16:45; (GMT\+3|UTC)/);
7
+ });
8
+ describe('return long time which is modified', () => {
9
+ it('Turkish (tr)', async () => {
10
+ expect((0, _getLongTime.getLongTime)('tr', new Date('2021-08-12 16:45'))).toMatch(/ÖS 4:45 (GMT\+3|UTC)/);
11
+ });
12
+ });
13
+ });
14
+ //# sourceMappingURL=getLongTime.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getLongTime","require","describe","it","expect","getLongTime","Date","toMatch"],"sources":["../../../../src/dateTimeFormat/getLongTime/getLongTime.spec.ts"],"sourcesContent":["import { getLongTime } from './getLongTime';\n\ndescribe('getLongTime', () => {\n it('to return long time generated by Intl', async () => {\n expect(getLongTime('lt', new Date('2021-08-12 16:45'))).toMatch(\n /16:45; (GMT\\+3|UTC)/\n );\n });\n\n describe('return long time which is modified', () => {\n it('Turkish (tr)', async () => {\n expect(getLongTime('tr', new Date('2021-08-12 16:45'))).toMatch(\n /ÖS 4:45 (GMT\\+3|UTC)/\n );\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC5BC,EAAE,CAAC,uCAAuC,EAAE,YAAY;IACtDC,MAAM,CAAC,IAAAC,wBAAW,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAACC,OAAO,CAC7D,qBACF,CAAC;EACH,CAAC,CAAC;EAEFL,QAAQ,CAAC,oCAAoC,EAAE,MAAM;IACnDC,EAAE,CAAC,cAAc,EAAE,YAAY;MAC7BC,MAAM,CAAC,IAAAC,wBAAW,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAACC,OAAO,CAC7D,sBACF,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getMediumDate = void 0;
5
+ /**
6
+ * Function that returns medium date format approved by Wix Localization team.
7
+ * @param locale - language/country short value that is passed to Intl.DateTimeFormat
8
+ * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.
9
+ */
10
+ const getMediumDate = (locale, date) => {
11
+ return new Intl.DateTimeFormat(locale, {
12
+ dateStyle: 'medium'
13
+ }).format(date);
14
+ };
15
+ exports.getMediumDate = getMediumDate;
16
+ //# sourceMappingURL=getMediumDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getMediumDate","locale","date","Intl","DateTimeFormat","dateStyle","format","exports"],"sources":["../../../../src/dateTimeFormat/getMediumDate/getMediumDate.ts"],"sourcesContent":["import { SupportedWixLocales } from '../../constants';\n\n/**\n * Function that returns medium date format approved by Wix Localization team.\n * @param locale - language/country short value that is passed to Intl.DateTimeFormat\n * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.\n */\nexport const getMediumDate = (locale: SupportedWixLocales, date: Date) => {\n return new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(date);\n};\n"],"mappings":";;;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAGA,CAACC,MAA2B,EAAEC,IAAU,KAAK;EACxE,OAAO,IAAIC,IAAI,CAACC,cAAc,CAACH,MAAM,EAAE;IAAEI,SAAS,EAAE;EAAS,CAAC,CAAC,CAACC,MAAM,CAACJ,IAAI,CAAC;AAC9E,CAAC;AAACK,OAAA,CAAAP,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var _getMediumDate = require("./getMediumDate");
4
+ describe('getMediumDate', () => {
5
+ it('to return medium date', async () => {
6
+ expect((0, _getMediumDate.getMediumDate)('en-US', new Date('2021-08-12'))).toBe('Aug 12, 2021');
7
+ });
8
+ });
9
+ //# sourceMappingURL=getMediumDate.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getMediumDate","require","describe","it","expect","getMediumDate","Date","toBe"],"sources":["../../../../src/dateTimeFormat/getMediumDate/getMediumDate.spec.ts"],"sourcesContent":["import { getMediumDate } from './getMediumDate';\n\ndescribe('getMediumDate', () => {\n it('to return medium date', async () => {\n expect(getMediumDate('en-US', new Date('2021-08-12'))).toBe('Aug 12, 2021');\n });\n});\n"],"mappings":";;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,eAAe,EAAE,MAAM;EAC9BC,EAAE,CAAC,uBAAuB,EAAE,YAAY;IACtCC,MAAM,CAAC,IAAAC,4BAAa,EAAC,OAAO,EAAE,IAAIC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,cAAc,CAAC;EAC7E,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getShortDate = void 0;
5
+ const splitDate = (locale, date, format = {}) => {
6
+ const {
7
+ year = 'numeric',
8
+ month = 'numeric',
9
+ day = 'numeric'
10
+ } = format;
11
+ return {
12
+ year: new Intl.DateTimeFormat(locale, {
13
+ year
14
+ }).format(date),
15
+ month: new Intl.DateTimeFormat(locale, {
16
+ month
17
+ }).format(date),
18
+ day: new Intl.DateTimeFormat(locale, {
19
+ day
20
+ }).format(date)
21
+ };
22
+ };
23
+ const modifiedShortDates = {
24
+ fi: date => {
25
+ const {
26
+ day,
27
+ month,
28
+ year
29
+ } = splitDate('fi', date);
30
+ return `${day}.${month}.${year}`;
31
+ },
32
+ ko: date => {
33
+ const {
34
+ day,
35
+ month,
36
+ year
37
+ } = splitDate('ko', date, {
38
+ month: '2-digit',
39
+ day: '2-digit'
40
+ });
41
+ return `${year}.${month}.${day}`.replace(/년|월|일/g, '');
42
+ },
43
+ sk: date => new Intl.DateTimeFormat('sk').format(date).replace(/ /g, ''),
44
+ nn: date => new Intl.DateTimeFormat('nn').format(date).replace(/\//g, '.'),
45
+ 'es-US': date => {
46
+ const {
47
+ day,
48
+ month,
49
+ year
50
+ } = splitDate('es-US', date);
51
+ return `${month}/${day}/${year}`;
52
+ },
53
+ sv: date => {
54
+ const {
55
+ day,
56
+ month,
57
+ year
58
+ } = splitDate('sv', date);
59
+ return `${day}/${month} ${year}`;
60
+ }
61
+ };
62
+
63
+ /**
64
+ * Function that returns short date format approved by Wix Localization team.
65
+ * @param locale - language/country short value that is passed to Intl.DateTimeFormat
66
+ * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.
67
+ */
68
+ const getShortDate = (locale, date) => {
69
+ if (modifiedShortDates[locale]) {
70
+ var _modifiedShortDates$l;
71
+ return (_modifiedShortDates$l = modifiedShortDates[locale]) == null ? void 0 : _modifiedShortDates$l.call(modifiedShortDates, date);
72
+ }
73
+ return new Intl.DateTimeFormat(locale, {
74
+ day: '2-digit',
75
+ month: '2-digit',
76
+ year: 'numeric'
77
+ }).format(date);
78
+ };
79
+ exports.getShortDate = getShortDate;
80
+ //# sourceMappingURL=getShortDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["splitDate","locale","date","format","year","month","day","Intl","DateTimeFormat","modifiedShortDates","fi","ko","replace","sk","nn","sv","getShortDate","_modifiedShortDates$l","call","exports"],"sources":["../../../../src/dateTimeFormat/getShortDate/getShortDate.ts"],"sourcesContent":["import { SupportedWixLocales } from '../../constants';\n\nconst splitDate = (\n locale: string,\n date: Date,\n format: {\n year?: 'numeric' | '2-digit';\n month?: 'numeric' | '2-digit';\n day?: 'numeric' | '2-digit';\n } = {}\n) => {\n const { year = 'numeric', month = 'numeric', day = 'numeric' } = format;\n\n return {\n year: new Intl.DateTimeFormat(locale, { year }).format(date),\n month: new Intl.DateTimeFormat(locale, { month }).format(date),\n day: new Intl.DateTimeFormat(locale, { day }).format(date),\n };\n};\n\nconst modifiedShortDates: Partial<\n Record<SupportedWixLocales, (date: Date) => string>\n> = {\n fi: (date: Date) => {\n const { day, month, year } = splitDate('fi', date);\n\n return `${day}.${month}.${year}`;\n },\n ko: (date: Date) => {\n const { day, month, year } = splitDate('ko', date, {\n month: '2-digit',\n day: '2-digit',\n });\n\n return `${year}.${month}.${day}`.replace(/년|월|일/g, '');\n },\n sk: (date: Date) =>\n new Intl.DateTimeFormat('sk').format(date).replace(/ /g, ''),\n nn: (date: Date) =>\n new Intl.DateTimeFormat('nn').format(date).replace(/\\//g, '.'),\n 'es-US': (date: Date) => {\n const { day, month, year } = splitDate('es-US', date);\n\n return `${month}/${day}/${year}`;\n },\n sv: (date: Date) => {\n const { day, month, year } = splitDate('sv', date);\n\n return `${day}/${month} ${year}`;\n },\n} as const;\n\n/**\n * Function that returns short date format approved by Wix Localization team.\n * @param locale - language/country short value that is passed to Intl.DateTimeFormat\n * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.\n */\nexport const getShortDate = (locale: SupportedWixLocales, date: Date) => {\n if (modifiedShortDates[locale]) {\n return modifiedShortDates[locale]?.(date);\n }\n\n return new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n }).format(date);\n};\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ var _getShortDate = require("./getShortDate");
4
+ describe('getShortDate', () => {
5
+ it('to return short date generated by Intl', async () => {
6
+ expect((0, _getShortDate.getShortDate)('fi', new Date('2021-08-12'))).toBe('12.8.2021');
7
+ });
8
+ describe('return short date which is modified', () => {
9
+ it('Finnish (fi)', async () => {
10
+ expect((0, _getShortDate.getShortDate)('fi', new Date('2021-08-12'))).toBe('12.8.2021');
11
+ });
12
+ it('Korean (ko)', async () => {
13
+ expect((0, _getShortDate.getShortDate)('ko', new Date('2021-08-12'))).toBe('2021.08.12');
14
+ });
15
+ it('Norwegian naynorsk (nn)', async () => {
16
+ expect((0, _getShortDate.getShortDate)('nn', new Date('2021-08-12'))).toBe('12.8.2021');
17
+ });
18
+ it('Slovak (sk)', async () => {
19
+ expect((0, _getShortDate.getShortDate)('sk', new Date('2021-08-12'))).toBe('12.8.2021');
20
+ });
21
+ it('Spanish-USA (es-US)', async () => {
22
+ expect((0, _getShortDate.getShortDate)('es-US', new Date('2021-08-12'))).toBe('8/12/2021');
23
+ });
24
+ it('Swedish (sv)', async () => {
25
+ expect((0, _getShortDate.getShortDate)('sv', new Date('2021-08-12'))).toBe('12/8 2021');
26
+ });
27
+ });
28
+ });
29
+ //# sourceMappingURL=getShortDate.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getShortDate","require","describe","it","expect","getShortDate","Date","toBe"],"sources":["../../../../src/dateTimeFormat/getShortDate/getShortDate.spec.ts"],"sourcesContent":["import { getShortDate } from './getShortDate';\n\ndescribe('getShortDate', () => {\n it('to return short date generated by Intl', async () => {\n expect(getShortDate('fi', new Date('2021-08-12'))).toBe('12.8.2021');\n });\n\n describe('return short date which is modified', () => {\n it('Finnish (fi)', async () => {\n expect(getShortDate('fi', new Date('2021-08-12'))).toBe('12.8.2021');\n });\n\n it('Korean (ko)', async () => {\n expect(getShortDate('ko', new Date('2021-08-12'))).toBe('2021.08.12');\n });\n\n it('Norwegian naynorsk (nn)', async () => {\n expect(getShortDate('nn', new Date('2021-08-12'))).toBe('12.8.2021');\n });\n\n it('Slovak (sk)', async () => {\n expect(getShortDate('sk', new Date('2021-08-12'))).toBe('12.8.2021');\n });\n\n it('Spanish-USA (es-US)', async () => {\n expect(getShortDate('es-US', new Date('2021-08-12'))).toBe('8/12/2021');\n });\n\n it('Swedish (sv)', async () => {\n expect(getShortDate('sv', new Date('2021-08-12'))).toBe('12/8 2021');\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,cAAc,EAAE,MAAM;EAC7BC,EAAE,CAAC,wCAAwC,EAAE,YAAY;IACvDC,MAAM,CAAC,IAAAC,0BAAY,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,WAAW,CAAC;EACtE,CAAC,CAAC;EAEFL,QAAQ,CAAC,qCAAqC,EAAE,MAAM;IACpDC,EAAE,CAAC,cAAc,EAAE,YAAY;MAC7BC,MAAM,CAAC,IAAAC,0BAAY,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,WAAW,CAAC;IACtE,CAAC,CAAC;IAEFJ,EAAE,CAAC,aAAa,EAAE,YAAY;MAC5BC,MAAM,CAAC,IAAAC,0BAAY,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,YAAY,CAAC;IACvE,CAAC,CAAC;IAEFJ,EAAE,CAAC,yBAAyB,EAAE,YAAY;MACxCC,MAAM,CAAC,IAAAC,0BAAY,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,WAAW,CAAC;IACtE,CAAC,CAAC;IAEFJ,EAAE,CAAC,aAAa,EAAE,YAAY;MAC5BC,MAAM,CAAC,IAAAC,0BAAY,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,WAAW,CAAC;IACtE,CAAC,CAAC;IAEFJ,EAAE,CAAC,qBAAqB,EAAE,YAAY;MACpCC,MAAM,CAAC,IAAAC,0BAAY,EAAC,OAAO,EAAE,IAAIC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,WAAW,CAAC;IACzE,CAAC,CAAC;IAEFJ,EAAE,CAAC,cAAc,EAAE,YAAY;MAC7BC,MAAM,CAAC,IAAAC,0BAAY,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,WAAW,CAAC;IACtE,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getShortTime = void 0;
5
+ const shortTimeOptions = {
6
+ hour: 'numeric',
7
+ minute: 'numeric'
8
+ };
9
+ const modifiedShortTimes = {
10
+ tr: date => new Intl.DateTimeFormat('tr', {
11
+ hour: '2-digit',
12
+ minute: '2-digit',
13
+ hour12: true
14
+ }).format(date)
15
+ };
16
+
17
+ /**
18
+ * Function that returns short time format approved by Wix Localization team.
19
+ * @param locale - language/country short value that is passed to Intl.DateTimeFormat
20
+ * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.
21
+ */
22
+ const getShortTime = (locale, date) => {
23
+ if (modifiedShortTimes[locale]) {
24
+ var _modifiedShortTimes$l;
25
+ return (_modifiedShortTimes$l = modifiedShortTimes[locale]) == null ? void 0 : _modifiedShortTimes$l.call(modifiedShortTimes, date);
26
+ }
27
+ return new Intl.DateTimeFormat(locale, shortTimeOptions).format(date);
28
+ };
29
+ exports.getShortTime = getShortTime;
30
+ //# sourceMappingURL=getShortTime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["shortTimeOptions","hour","minute","modifiedShortTimes","tr","date","Intl","DateTimeFormat","hour12","format","getShortTime","locale","_modifiedShortTimes$l","call","exports"],"sources":["../../../../src/dateTimeFormat/getShortTime/getShortTime.ts"],"sourcesContent":["import { SupportedWixLocales } from '../../constants';\n\nconst shortTimeOptions: {\n hour: '2-digit' | 'numeric';\n minute: '2-digit' | 'numeric';\n} = {\n hour: 'numeric',\n minute: 'numeric',\n};\n\nconst modifiedShortTimes: Partial<\n Record<SupportedWixLocales, (date: Date) => string>\n> = {\n tr: (date: Date) =>\n new Intl.DateTimeFormat('tr', {\n hour: '2-digit',\n minute: '2-digit',\n hour12: true,\n }).format(date),\n} as const;\n\n/**\n * Function that returns short time format approved by Wix Localization team.\n * @param locale - language/country short value that is passed to Intl.DateTimeFormat\n * @param date - JavaScript Date objects represent a single moment in time in a platform-independent format.\n */\nexport const getShortTime = (locale: SupportedWixLocales, date: Date) => {\n if (modifiedShortTimes[locale]) {\n return modifiedShortTimes[locale]?.(date);\n }\n\n return new Intl.DateTimeFormat(locale, shortTimeOptions).format(date);\n};\n"],"mappings":";;;;AAEA,MAAMA,gBAGL,GAAG;EACFC,IAAI,EAAE,SAAS;EACfC,MAAM,EAAE;AACV,CAAC;AAED,MAAMC,kBAEL,GAAG;EACFC,EAAE,EAAGC,IAAU,IACb,IAAIC,IAAI,CAACC,cAAc,CAAC,IAAI,EAAE;IAC5BN,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,SAAS;IACjBM,MAAM,EAAE;EACV,CAAC,CAAC,CAACC,MAAM,CAACJ,IAAI;AAClB,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACO,MAAMK,YAAY,GAAGA,CAACC,MAA2B,EAAEN,IAAU,KAAK;EACvE,IAAIF,kBAAkB,CAACQ,MAAM,CAAC,EAAE;IAAA,IAAAC,qBAAA;IAC9B,QAAAA,qBAAA,GAAOT,kBAAkB,CAACQ,MAAM,CAAC,qBAA1BC,qBAAA,CAAAC,IAAA,CAAAV,kBAAkB,EAAWE,IAAI,CAAC;EAC3C;EAEA,OAAO,IAAIC,IAAI,CAACC,cAAc,CAACI,MAAM,EAAEX,gBAAgB,CAAC,CAACS,MAAM,CAACJ,IAAI,CAAC;AACvE,CAAC;AAACS,OAAA,CAAAJ,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _getShortTime = require("./getShortTime");
4
+ describe('getShortTime', () => {
5
+ it('to return short time generated by Intl', async () => {
6
+ expect((0, _getShortTime.getShortTime)('lt', new Date('2021-08-12 16:45'))).toBe('16:45');
7
+ });
8
+ describe('return short time which is modified', () => {
9
+ it('Turkish (tr)', async () => {
10
+ expect((0, _getShortTime.getShortTime)('tr', new Date('2021-08-12 16:45'))).toBe('ÖS 04:45');
11
+ });
12
+ });
13
+ });
14
+ //# sourceMappingURL=getShortTime.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getShortTime","require","describe","it","expect","getShortTime","Date","toBe"],"sources":["../../../../src/dateTimeFormat/getShortTime/getShortTime.spec.ts"],"sourcesContent":["import { getShortTime } from './getShortTime';\n\ndescribe('getShortTime', () => {\n it('to return short time generated by Intl', async () => {\n expect(getShortTime('lt', new Date('2021-08-12 16:45'))).toBe('16:45');\n });\n\n describe('return short time which is modified', () => {\n it('Turkish (tr)', async () => {\n expect(getShortTime('tr', new Date('2021-08-12 16:45'))).toBe('ÖS 04:45');\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,cAAc,EAAE,MAAM;EAC7BC,EAAE,CAAC,wCAAwC,EAAE,YAAY;IACvDC,MAAM,CAAC,IAAAC,0BAAY,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,OAAO,CAAC;EACxE,CAAC,CAAC;EAEFL,QAAQ,CAAC,qCAAqC,EAAE,MAAM;IACpDC,EAAE,CAAC,cAAc,EAAE,YAAY;MAC7BC,MAAM,CAAC,IAAAC,0BAAY,EAAC,IAAI,EAAE,IAAIC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,UAAU,CAAC;IAC3E,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getYear = void 0;
5
+ const yearOptions = {
6
+ year: 'numeric'
7
+ };
8
+
9
+ /**
10
+ * Return the string used to format the year for the given date. E.g ‘2023年’
11
+ * @param date - a given date
12
+ * @returns {string} - the string of the given date
13
+ * */
14
+ const getYear = (locale, date) => {
15
+ return new Intl.DateTimeFormat(locale, yearOptions).format(date);
16
+ };
17
+ exports.getYear = getYear;
18
+ //# sourceMappingURL=getYear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["yearOptions","year","getYear","locale","date","Intl","DateTimeFormat","format","exports"],"sources":["../../../../src/dateTimeFormat/getYear/getYear.ts"],"sourcesContent":["import { SupportedWixLocales } from '../../constants';\n\nconst yearOptions = {\n year: 'numeric',\n} as const;\n\n/**\n * Return the string used to format the year for the given date. E.g ‘2023年’\n * @param date - a given date\n * @returns {string} - the string of the given date\n * */\nexport const getYear = (locale: SupportedWixLocales, date: Date): string => {\n return new Intl.DateTimeFormat(locale, yearOptions).format(date);\n};\n"],"mappings":";;;;AAEA,MAAMA,WAAW,GAAG;EAClBC,IAAI,EAAE;AACR,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACO,MAAMC,OAAO,GAAGA,CAACC,MAA2B,EAAEC,IAAU,KAAa;EAC1E,OAAO,IAAIC,IAAI,CAACC,cAAc,CAACH,MAAM,EAAEH,WAAW,CAAC,CAACO,MAAM,CAACH,IAAI,CAAC;AAClE,CAAC;AAACI,OAAA,CAAAN,OAAA,GAAAA,OAAA","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ var _constants = require("../../constants");
4
+ var _getYear = require("./getYear");
5
+ const FORMATTED_YEAR_LOCALES_DATA = [{
6
+ locale: 'ko',
7
+ expectedYear: '2022년'
8
+ }, {
9
+ locale: 'ja',
10
+ expectedYear: '2022年'
11
+ }, {
12
+ locale: 'ar',
13
+ expectedYear: '2022'
14
+ }, {
15
+ locale: 'bg',
16
+ expectedYear: '2022 г.'
17
+ }, {
18
+ locale: 'hu',
19
+ expectedYear: '2022.'
20
+ }, {
21
+ locale: 'th',
22
+ expectedYear: 'พ.ศ. 2565'
23
+ }, {
24
+ locale: 'zh',
25
+ expectedYear: '2022年'
26
+ }, {
27
+ locale: 'zh-TW',
28
+ expectedYear: '2022年'
29
+ }, {
30
+ locale: 'zh-HK',
31
+ expectedYear: '2022年'
32
+ }, {
33
+ locale: 'zh-MO',
34
+ expectedYear: '2022年'
35
+ }];
36
+ const UNFORMATTED_YEAR_LOCALES = _constants.SupportedWixLocales.filter(locale => {
37
+ return !FORMATTED_YEAR_LOCALES_DATA.find(data => data.locale === locale);
38
+ });
39
+ describe('getYear', () => {
40
+ const year = new Date('2022-01-01T00:00:00Z');
41
+ for (const data of FORMATTED_YEAR_LOCALES_DATA) {
42
+ it(`should return formatted year ${data.locale}`, () => {
43
+ const localizedYear = (0, _getYear.getYear)(data.locale, year);
44
+ expect(localizedYear).toBe(data.expectedYear);
45
+ });
46
+ }
47
+ for (const locale of UNFORMATTED_YEAR_LOCALES) {
48
+ it(`should return unformatted year ${locale} `, () => {
49
+ const localizedYear = (0, _getYear.getYear)(locale, year);
50
+ expect(localizedYear).toBe('2022');
51
+ });
52
+ }
53
+ });
54
+ //# sourceMappingURL=getYear.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_constants","require","_getYear","FORMATTED_YEAR_LOCALES_DATA","locale","expectedYear","UNFORMATTED_YEAR_LOCALES","SupportedWixLocales","filter","find","data","describe","year","Date","it","localizedYear","getYear","expect","toBe"],"sources":["../../../../src/dateTimeFormat/getYear/getYear.spec.ts"],"sourcesContent":["import { SupportedWixLocales } from '../../constants';\nimport { getYear } from './getYear';\n\nconst FORMATTED_YEAR_LOCALES_DATA: {\n locale: SupportedWixLocales;\n expectedYear: string;\n}[] = [\n {\n locale: 'ko',\n expectedYear: '2022년',\n },\n {\n locale: 'ja',\n expectedYear: '2022年',\n },\n {\n locale: 'ar',\n expectedYear: '2022',\n },\n {\n locale: 'bg',\n expectedYear: '2022 г.',\n },\n {\n locale: 'hu',\n expectedYear: '2022.',\n },\n {\n locale: 'th',\n expectedYear: 'พ.ศ. 2565',\n },\n {\n locale: 'zh',\n expectedYear: '2022年',\n },\n {\n locale: 'zh-TW',\n expectedYear: '2022年',\n },\n {\n locale: 'zh-HK',\n expectedYear: '2022年',\n },\n {\n locale: 'zh-MO',\n expectedYear: '2022年',\n },\n];\n\nconst UNFORMATTED_YEAR_LOCALES = SupportedWixLocales.filter((locale) => {\n return !FORMATTED_YEAR_LOCALES_DATA.find((data) => data.locale === locale);\n});\n\ndescribe('getYear', () => {\n const year = new Date('2022-01-01T00:00:00Z');\n\n for (const data of FORMATTED_YEAR_LOCALES_DATA) {\n it(`should return formatted year ${data.locale}`, () => {\n const localizedYear = getYear(data.locale, year);\n expect(localizedYear).toBe(data.expectedYear);\n });\n }\n\n for (const locale of UNFORMATTED_YEAR_LOCALES) {\n it(`should return unformatted year ${locale} `, () => {\n const localizedYear = getYear(locale, year);\n expect(localizedYear).toBe('2022');\n });\n }\n});\n"],"mappings":";;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,2BAGH,GAAG,CACJ;EACEC,MAAM,EAAE,IAAI;EACZC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,IAAI;EACZC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,IAAI;EACZC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,IAAI;EACZC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,IAAI;EACZC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,IAAI;EACZC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,IAAI;EACZC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,OAAO;EACfC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,OAAO;EACfC,YAAY,EAAE;AAChB,CAAC,EACD;EACED,MAAM,EAAE,OAAO;EACfC,YAAY,EAAE;AAChB,CAAC,CACF;AAED,MAAMC,wBAAwB,GAAGC,8BAAmB,CAACC,MAAM,CAAEJ,MAAM,IAAK;EACtE,OAAO,CAACD,2BAA2B,CAACM,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACN,MAAM,KAAKA,MAAM,CAAC;AAC5E,CAAC,CAAC;AAEFO,QAAQ,CAAC,SAAS,EAAE,MAAM;EACxB,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAAC,sBAAsB,CAAC;EAE7C,KAAK,MAAMH,IAAI,IAAIP,2BAA2B,EAAE;IAC9CW,EAAE,CAAC,gCAAgCJ,IAAI,CAACN,MAAM,EAAE,EAAE,MAAM;MACtD,MAAMW,aAAa,GAAG,IAAAC,gBAAO,EAACN,IAAI,CAACN,MAAM,EAAEQ,IAAI,CAAC;MAChDK,MAAM,CAACF,aAAa,CAAC,CAACG,IAAI,CAACR,IAAI,CAACL,YAAY,CAAC;IAC/C,CAAC,CAAC;EACJ;EAEA,KAAK,MAAMD,MAAM,IAAIE,wBAAwB,EAAE;IAC7CQ,EAAE,CAAC,kCAAkCV,MAAM,GAAG,EAAE,MAAM;MACpD,MAAMW,aAAa,GAAG,IAAAC,gBAAO,EAACZ,MAAM,EAAEQ,IAAI,CAAC;MAC3CK,MAAM,CAACF,aAAa,CAAC,CAACG,IAAI,CAAC,MAAM,CAAC;IACpC,CAAC,CAAC;EACJ;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.dateTimeFormat = void 0;
5
+ var _dateTimeFormat = require("./dateTimeFormat");
6
+ exports.dateTimeFormat = _dateTimeFormat.dateTimeFormat;
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dateTimeFormat","require","exports","dateTimeFormat"],"sources":["../../../src/dateTimeFormat/index.ts"],"sourcesContent":["export { dateTimeFormat } from './dateTimeFormat';\n"],"mappings":";;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAkDC,OAAA,CAAAC,cAAA,GAAAH,eAAA,CAAAG,cAAA","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ var _exportNames = {
5
+ SupportedWixLocales: true
6
+ };
7
+ exports.SupportedWixLocales = void 0;
8
+ var _dateTimeFormat = require("./dateTimeFormat");
9
+ Object.keys(_dateTimeFormat).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
12
+ if (key in exports && exports[key] === _dateTimeFormat[key]) return;
13
+ exports[key] = _dateTimeFormat[key];
14
+ });
15
+ var _constants = require("./constants");
16
+ exports.SupportedWixLocales = _constants.SupportedWixLocales;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dateTimeFormat","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","_constants","SupportedWixLocales"],"sources":["../../src/index.ts"],"sourcesContent":["export * from './dateTimeFormat';\nexport { SupportedWixLocales } from './constants';\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAK,OAAA,CAAAL,GAAA,IAAAL,eAAA,CAAAK,GAAA;AAAA;AACA,IAAAM,UAAA,GAAAV,OAAA;AAAkDS,OAAA,CAAAE,mBAAA,GAAAD,UAAA,CAAAC,mBAAA","ignoreList":[]}
@@ -0,0 +1,57 @@
1
+ export const SupportedWixLocales = [
2
+ 'en',
3
+ 'en-US',
4
+ 'en-GB',
5
+ 'en-AU',
6
+ 'en-CA',
7
+ 'ar',
8
+ 'bg',
9
+ 'ca',
10
+ 'zh',
11
+ 'zh-TW',
12
+ 'zh-HK',
13
+ 'zh-MO',
14
+ 'cs',
15
+ 'da',
16
+ 'nl',
17
+ 'fi',
18
+ 'fr',
19
+ 'fr-CA',
20
+ 'fr-CH',
21
+ 'fr-BE',
22
+ 'de',
23
+ 'de-CH',
24
+ 'de-AT',
25
+ 'el',
26
+ 'he',
27
+ 'hi',
28
+ 'hu',
29
+ 'id',
30
+ 'it',
31
+ 'ja',
32
+ 'ko',
33
+ 'lt',
34
+ 'ms',
35
+ 'no',
36
+ 'nb',
37
+ 'nn',
38
+ 'pl',
39
+ 'pt-BR',
40
+ 'pt',
41
+ 'ro',
42
+ 'ru',
43
+ 'sk',
44
+ 'sl',
45
+ 'es',
46
+ 'es-419',
47
+ 'es-AR',
48
+ 'es-MX',
49
+ 'es-US',
50
+ 'sv',
51
+ 'tl',
52
+ 'th',
53
+ 'tr',
54
+ 'uk',
55
+ 'vi',
56
+ ];
57
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,IAAI;IACJ,OAAO;IACP,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACI,CAAC"}