@js-joda/locale 4.2.1 → 4.6.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 (61) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/js-joda-locale.esm.js +1823 -0
  3. package/dist/js-joda-locale.js +1095 -1297
  4. package/dist/js-joda-locale.js.map +1 -1
  5. package/dist/js-joda-locale.min.js +9 -36
  6. package/dist/prebuilt/de/index.js +1105 -1307
  7. package/dist/prebuilt/de/index.js.map +1 -1
  8. package/dist/prebuilt/de-de/index.js +1105 -1307
  9. package/dist/prebuilt/de-de/index.js.map +1 -1
  10. package/dist/prebuilt/en/index.js +1106 -1308
  11. package/dist/prebuilt/en/index.js.map +1 -1
  12. package/dist/prebuilt/en-us/index.js +1105 -1307
  13. package/dist/prebuilt/en-us/index.js.map +1 -1
  14. package/dist/prebuilt/es/index.js +1106 -1308
  15. package/dist/prebuilt/es/index.js.map +1 -1
  16. package/dist/prebuilt/fr/index.js +1106 -1308
  17. package/dist/prebuilt/fr/index.js.map +1 -1
  18. package/dist/prebuilt/fr-fr/index.js +1105 -1307
  19. package/dist/prebuilt/fr-fr/index.js.map +1 -1
  20. package/dist/prebuilt/hi/index.js +1105 -1307
  21. package/dist/prebuilt/hi/index.js.map +1 -1
  22. package/dist/prebuilt/it/index.js +1105 -1307
  23. package/dist/prebuilt/it/index.js.map +1 -1
  24. package/dist/prebuilt/it-it/index.js +1105 -1307
  25. package/dist/prebuilt/it-it/index.js.map +1 -1
  26. package/dist/prebuilt/ja/index.js +1105 -1307
  27. package/dist/prebuilt/ja/index.js.map +1 -1
  28. package/dist/prebuilt/ja-jp/index.js +1105 -1307
  29. package/dist/prebuilt/ja-jp/index.js.map +1 -1
  30. package/dist/prebuilt/ko/index.js +1105 -1307
  31. package/dist/prebuilt/ko/index.js.map +1 -1
  32. package/dist/prebuilt/ro/index.js +1105 -1307
  33. package/dist/prebuilt/ro/index.js.map +1 -1
  34. package/dist/prebuilt/ru/index.js +4035 -0
  35. package/dist/prebuilt/ru/index.js.map +1 -0
  36. package/dist/prebuilt/sv/index.js +1105 -1307
  37. package/dist/prebuilt/sv/index.js.map +1 -1
  38. package/dist/prebuilt/sv-se/index.js +1105 -1307
  39. package/dist/prebuilt/sv-se/index.js.map +1 -1
  40. package/dist/prebuilt/zh/index.js +1105 -1307
  41. package/dist/prebuilt/zh/index.js.map +1 -1
  42. package/package.json +24 -17
  43. package/src/Locale.js +8 -0
  44. package/src/js-joda-locale.js +3 -1
  45. package/{dist → typings}/js-joda-locale.d.ts +28 -2
  46. package/.babelrc +0 -24
  47. package/build_package.default.json +0 -14
  48. package/build_package.prebuilt.json +0 -66
  49. package/examples/usage_browser.html +0 -111
  50. package/examples/usage_browser_build.html +0 -72
  51. package/examples/usage_es6.js +0 -15
  52. package/examples/usage_node.js +0 -38
  53. package/examples/usage_node_build.js +0 -48
  54. package/utils/CldrDataIgnorePlugin.js +0 -57
  55. package/utils/README_package.template.md +0 -13
  56. package/utils/buildWebpackConfig.js +0 -28
  57. package/utils/build_package.js +0 -170
  58. package/utils/create_packages.js +0 -136
  59. package/utils/load_cldrData.prebuilt.js +0 -18
  60. package/utils/publish_release.js +0 -151
  61. package/webpack.config.js +0 -88
package/package.json CHANGED
@@ -1,16 +1,33 @@
1
1
  {
2
2
  "name": "@js-joda/locale",
3
- "version": "4.2.1",
3
+ "version": "4.6.0",
4
4
  "description": "plugin for locale functionality for js-joda",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/js-joda/js-joda.git"
8
8
  },
9
+ "author": "phueper",
10
+ "contributors": [
11
+ "pithu",
12
+ "phueper"
13
+ ],
14
+ "homepage": "https://js-joda.github.io/js-joda",
15
+ "license": "BSD-3-Clause",
16
+ "bugs": {
17
+ "url": "https://github.com/js-joda/js-joda/issues"
18
+ },
9
19
  "main": "dist/js-joda-locale.js",
10
- "typings": "dist/js-joda-locale.d.ts",
20
+ "typings": "typings/js-joda-locale.d.ts",
21
+ "files": [
22
+ "dist",
23
+ "src",
24
+ "typings",
25
+ "CHANGELOG.md",
26
+ "README.md"
27
+ ],
11
28
  "scripts": {
12
- "version": "npm run build-locale-dist",
13
- "test": "npx mocha --timeout 5000 --require @babel/register ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js test/pluginTest_mochaOnly.js",
29
+ "prepublishOnly": "npm run build-locale-dist",
30
+ "test": "NODE_ENV=test npx mocha --timeout 5000 --require @babel/register ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js test/pluginTest_mochaOnly.js",
14
31
  "test-coverage": "NODE_ENV=test COVERAGE=1 npx nyc --report-dir=build/coverage --reporter=lcov --reporter html npx mocha --timeout 5000 --require @babel/register --reporter progress ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js",
15
32
  "test-browser": "npx karma start --reporters=dots --single-run",
16
33
  "test-saucelabs": "npx karma start --reporters=\"dots,saucelabs\" --browsers=\"sl_chrome,sl_ie,sl_firefox,sl_ios_simulator\" --single-run=true",
@@ -37,16 +54,6 @@
37
54
  "yargs": {
38
55
  "camel-case-expansion": false
39
56
  },
40
- "author": "phueper",
41
- "contributors": [
42
- "pithu",
43
- "phueper"
44
- ],
45
- "license": "BSD-3-Clause",
46
- "bugs": {
47
- "url": "https://github.com/js-joda/js-joda-locale/issues"
48
- },
49
- "homepage": "https://github.com/js-joda/js-joda-locale#readme",
50
57
  "peerDependencies": {
51
58
  "@js-joda/core": ">=3.2.0",
52
59
  "@js-joda/timezone": "^2.3.0",
@@ -54,12 +61,12 @@
54
61
  "cldrjs": "^0.5.4"
55
62
  },
56
63
  "devDependencies": {
57
- "@js-joda/core": "^4.2.1",
58
- "@js-joda/timezone": "^2.7.1",
64
+ "@js-joda/core": "^5.1.0",
65
+ "@js-joda/timezone": "^2.11.1",
59
66
  "cldr-data": "^36.0.0",
60
67
  "cldrjs": "^0.5.5"
61
68
  },
62
69
  "cldr-data-coverage": "core",
63
70
  "cldr-data-urls-filter": "(cldr-core|cldr-numbers-modern|cldr-dates-modern)",
64
- "gitHead": "485c4b2be852563615e2d2a8c3f0bca22d86bcd4"
71
+ "gitHead": "dda0bbb3894919782d859060bbabbaa3859775a8"
65
72
  }
package/src/Locale.js CHANGED
@@ -65,4 +65,12 @@ export function _init() {
65
65
  Locale.KOREAN = new Locale('ko');
66
66
  Locale.JAPANESE = new Locale('ja', 'JP');
67
67
  Locale.JAPAN = new Locale('ja', 'JP', 'ja');
68
+ Locale.ITALIAN = new Locale('it');
69
+ Locale.ITALY = new Locale('it', 'IT', 'it');
70
+ Locale.CHINESE = new Locale('zh');
71
+ Locale.ROMANIAN = new Locale('ro');
72
+ Locale.SWEDISH = new Locale('sv');
73
+ Locale.SWEDEN = new Locale('sv', 'SE', 'sv');
74
+ Locale.HINDI = new Locale('hi');
75
+ Locale.RUSSIAN = new Locale('ru');
68
76
  }
@@ -5,9 +5,11 @@
5
5
  import { use } from '@js-joda/core';
6
6
  import plug from './plug';
7
7
  import Locale from './Locale';
8
+ import { WeekFields } from './temporal/WeekFields';
8
9
 
9
10
  use(plug);
10
11
 
11
12
  export {
12
- Locale
13
+ Locale,
14
+ WeekFields
13
15
  };
@@ -1,3 +1,5 @@
1
+ import * as core from '@js-joda/core';
2
+
1
3
  export class Locale {
2
4
  public static getAvailableLocales(): string[];
3
5
 
@@ -10,6 +12,23 @@ export class Locale {
10
12
  public equals(other: any): boolean;
11
13
  }
12
14
 
15
+ export class WeekFields {
16
+ public static ISO: WeekFields;
17
+ public static SUNDAY_START: WeekFields;
18
+ public static of(locale: Locale): WeekFields;
19
+ public static of(firstDayOfWeek: core.DayOfWeek, minDays: number): WeekFields;
20
+ public firstDayOfWeek(): core.DayOfWeek;
21
+ public minimalDaysInFirstWeek(): number;
22
+ public dayOfWeek(): core.TemporalField;
23
+ public weekOfMonth(): core.TemporalField;
24
+ public weekOfYear(): core.TemporalField;
25
+ public weekOfWeekBasedYear(): core.TemporalField;
26
+ public weekBasedYear(): core.TemporalField;
27
+ public equals(other: any): boolean;
28
+ public hashCode(): number;
29
+ public toString(): string;
30
+ }
31
+
13
32
  export namespace Locale {
14
33
  const ENGLISH: Locale;
15
34
  const US: Locale;
@@ -22,10 +41,16 @@ export namespace Locale {
22
41
  const KOREAN: Locale;
23
42
  const JAPANESE: Locale;
24
43
  const JAPAN: Locale;
44
+ const ITALIAN: Locale;
45
+ const ITALY: Locale;
46
+ const CHINESE: Locale;
47
+ const ROMANIAN: Locale;
48
+ const SWEDISH: Locale;
49
+ const SWEDEN: Locale;
50
+ const HINDI: Locale;
51
+ const RUSSIAN: Locale;
25
52
  }
26
53
 
27
- import * as core from '@js-joda/core';
28
-
29
54
  declare module '@js-joda/core' {
30
55
  namespace DateTimeFormatter {
31
56
  export const RFC_1123_DATE_TIME: DateTimeFormatter;
@@ -42,6 +67,7 @@ declare module '@js-joda/core' {
42
67
  appendZoneText(textStyle: core.TextStyle): DateTimeFormatterBuilder;
43
68
  appendLocalizedOffset(textStyle: core.TextStyle): DateTimeFormatterBuilder;
44
69
  }
70
+
45
71
  }
46
72
 
47
73
  export const __esModule: true;
package/.babelrc DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "presets": [
3
- ["@babel/preset-env", {
4
- "modules": "auto",
5
- "targets": {
6
- "edge": "17",
7
- "firefox": "60",
8
- "chrome": "67",
9
- "safari": "11.1",
10
- "ie": "11"
11
- }
12
- }]
13
- ],
14
- "comments": false,
15
- "env": {
16
- "test": {
17
- "presets": ["@babel/preset-env", {
18
- "plugins": [
19
- "istanbul"
20
- ]
21
- }]
22
- }
23
- }
24
- }
@@ -1,14 +0,0 @@
1
- {
2
- "cldrDataLoader": "utils/load_cldrData.postinstall.js",
3
- "packages": {
4
- "de": [
5
- "de.*"
6
- ],
7
- "en": [
8
- "en.*"
9
- ],
10
- "es": [
11
- "es.*"
12
- ]
13
- }
14
- }
@@ -1,66 +0,0 @@
1
- {
2
- "modulesDir": "node_modules",
3
- "output": "dist/prebuilt",
4
- "cldrDataLoader": "utils/load_cldrData.prebuilt.js",
5
- "stats": false,
6
- "packages": {
7
- "de": [
8
- "de.*"
9
- ],
10
- "de-de": [
11
- "de",
12
- "de-DE"
13
- ],
14
- "en": [
15
- "en.*"
16
- ],
17
- "en-us": [
18
- "en",
19
- "en-US"
20
- ],
21
- "es": [
22
- "es.*"
23
- ],
24
- "fr": [
25
- "fr.*"
26
- ],
27
- "fr-fr": [
28
- "fr",
29
- "fr-FR"
30
- ],
31
- "it": [
32
- "it.*"
33
- ],
34
- "it-it": [
35
- "it",
36
- "it-IT"
37
- ],
38
- "ja": [
39
- "ja.*"
40
- ],
41
- "ja-jp": [
42
- "ja",
43
- "ja-JP"
44
- ],
45
- "ro": [
46
- "ro",
47
- "ro.*"
48
- ],
49
- "sv": [
50
- "sv.*"
51
- ],
52
- "sv-se": [
53
- "sv",
54
- "sv-SE"
55
- ],
56
- "zh": [
57
- "zh.*"
58
- ],
59
- "hi": [
60
- "hi.*"
61
- ],
62
- "ko": [
63
- "ko.*"
64
- ]
65
- }
66
- }
@@ -1,111 +0,0 @@
1
- <!DOCTYPE html>
2
- <!--
3
- ~ @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
4
- ~ @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
5
- -->
6
-
7
- <html lang="en">
8
- <head>
9
- <meta charset="UTF-8">
10
- <title>js-joda-locale Usage Example</title>
11
- <script type="text/javascript" src="../node_modules/requirejs/require.js"></script>
12
- </head>
13
- <body>
14
- <div class="out"/>
15
- <script type="text/javascript">
16
- require.config({
17
- paths: {
18
-
19
- // Unicode CLDR JSON data.
20
- 'cldr-data': "../node_modules/cldr-data",
21
-
22
- // require.js plugin we'll use to fetch CLDR JSON content.
23
- json: "../node_modules/requirejs-json/json",
24
-
25
- // text is json's dependency.
26
- text: "../node_modules/requirejs-text/text",
27
-
28
- '@js-joda/core': '../node_modules/@js-joda/core/dist/js-joda',
29
-
30
- '@js-joda/timezone': '../node_modules/@js-joda/timezone/dist/js-joda-timezone',
31
-
32
- '@js-joda/locale': '../dist/js-joda-locale',
33
-
34
- cldrjs: '../node_modules/cldrjs/dist/cldr',
35
-
36
- }
37
- });
38
- /* define cldr-data module that preloads and returns the necessary data when used
39
- from within js-joda-locale implementation
40
- */
41
- define('cldr-data', [
42
- // CLDR content, all files that are needed must be required here and can then be dynamically required below
43
- "json!cldr-data/supplemental/likelySubtags.json",
44
- "json!cldr-data/supplemental/metaZones.json",
45
- "json!cldr-data/supplemental/weekData.json",
46
- "json!cldr-data/main/en/ca-gregorian.json",
47
- "json!cldr-data/main/en/timeZoneNames.json",
48
- "json!cldr-data/main/en-CA/ca-gregorian.json",
49
- "json!cldr-data/main/en-CA/timeZoneNames.json",
50
- "json!cldr-data/main/en-GB/ca-gregorian.json",
51
- "json!cldr-data/main/en-GB/timeZoneNames.json",
52
- "json!cldr-data/main/de/ca-gregorian.json",
53
- "json!cldr-data/main/de/timeZoneNames.json",
54
- "json!cldr-data/main/fr/ca-gregorian.json",
55
- "json!cldr-data/main/fr/timeZoneNames.json",
56
- "json!cldr-data/main/es/ca-gregorian.json",
57
- "json!cldr-data/main/es/timeZoneNames.json",
58
- "json!cldr-data/main/ru/ca-gregorian.json",
59
- "json!cldr-data/main/ru/timeZoneNames.json",
60
- "json!cldr-data/main/zh/ca-gregorian.json",
61
- "json!cldr-data/main/zh/timeZoneNames.json",
62
- "json!cldr-data/main/hi/ca-gregorian.json",
63
- "json!cldr-data/main/hi/timeZoneNames.json",
64
- ], function (){
65
- return function(path) {
66
- return (require('json!cldr-data/' + path));
67
- }
68
- });
69
- require([
70
- '@js-joda/core',
71
- '@js-joda/timezone',
72
- '@js-joda/locale',
73
- ], function (JSJoda, JSJodaTimezone, JSJodaLocale) {
74
- function output(s) {
75
- console.log(s);
76
- var outDiv = document.getElementsByClassName('out')[0];
77
- var p = document.createElement('p');
78
- p.innerHTML = s;
79
- outDiv.appendChild(p);
80
- }
81
-
82
- let outputDateInDifferentLocales = function (zdt) {
83
- output('Times in ' + zdt.zone());
84
- output('&nbsp;');
85
- output('en_US formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.US)));
86
- output('en_CA formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.CANADA)));
87
- output('en_GB formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.UK)));
88
- output('de_DE formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.GERMANY)));
89
- output('fr_FR formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.FRANCE)));
90
- output('es_ES formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('es', 'ES ', 'es'))));
91
- output('ru_RU formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('ru', 'RU ', 'ru'))));
92
- output('zh_CN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('zh', 'CN ', 'zh'))));
93
- output('hi_IN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('hi', 'IN ', 'hi'))));
94
- output('&nbsp;');
95
- output('<hr />');
96
- }
97
-
98
- var zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('Europe/Berlin'));
99
- outputDateInDifferentLocales(zdt)
100
- zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('America/Chicago'));
101
- outputDateInDifferentLocales(zdt)
102
- zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('America/New_York'));
103
- outputDateInDifferentLocales(zdt);
104
- zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('Asia/Hong_Kong'));
105
- outputDateInDifferentLocales(zdt);
106
- }, function errorCallback(err) {
107
- output(err);
108
- });
109
- </script>
110
- </body>
111
- </html>
@@ -1,72 +0,0 @@
1
- <!DOCTYPE html>
2
- <!--
3
- ~ @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
4
- ~ @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
5
- -->
6
-
7
- <html lang="en">
8
- <head>
9
- <meta charset="UTF-8">
10
- <title>js-joda-locale Usage Example</title>
11
- <script type="text/javascript" src="../node_modules/requirejs/require.js"></script>
12
- </head>
13
- <body>
14
- <div class="out" />
15
- <script type="text/javascript">
16
- function output(s) {
17
- console.log(s);
18
- var outDiv = document.getElementsByClassName('out')[0];
19
- var p = document.createElement('p');
20
- p.innerHTML = s;
21
- outDiv.appendChild(p);
22
- }
23
-
24
- require.config({
25
- paths: {
26
- '@js-joda/core': '../node_modules/@js-joda/core/dist/js-joda',
27
-
28
- '@js-joda/timezone': '../node_modules/@js-joda/timezone/dist/js-joda-timezone',
29
-
30
- '@js-joda/locale': '../examples/build/js-joda-locale/index',
31
- }
32
- });
33
- require([
34
- '@js-joda/core',
35
- '@js-joda/timezone',
36
- '@js-joda/locale',
37
- ], function (JSJoda, JSJodaTimezone, JSJodaLocale) {
38
-
39
- function outputDateInDifferentLocales(zdt) {
40
- output('Times in ' + zdt.zone());
41
- output('&nbsp;');
42
- output('en_US formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.US)));
43
- output('en_CA formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.CANADA)));
44
- output('en_GB formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.UK)));
45
- output('de_DE formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.GERMANY)));
46
- output('fr_FR formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.FRANCE)));
47
- output('es_ES formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('es', 'ES ', 'es'))));
48
- output('ru_RU formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('ru', 'RU ', 'ru'))));
49
- output('zh_CN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('zh', 'CN ', 'zh'))));
50
- output('hi_IN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('hi', 'IN ', 'hi'))));
51
- output('&nbsp;');
52
- output('<hr />');
53
- }
54
-
55
- var zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('Europe/Berlin'));
56
- outputDateInDifferentLocales(zdt)
57
- zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('America/Chicago'));
58
- outputDateInDifferentLocales(zdt)
59
- zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('America/New_York'));
60
- outputDateInDifferentLocales(zdt);
61
- zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('Asia/Hong_Kong'));
62
- outputDateInDifferentLocales(zdt);
63
- }, function errorCallback(err) {
64
- output(err);
65
- output('<hr />');
66
- output('If you get a Script error for js-joda-locale above, you may need to run ');
67
- output('<pre>npm run build-examples</pre>');
68
- output('before using this example');
69
- });
70
- </script>
71
- </body>
72
- </html>
@@ -1,15 +0,0 @@
1
- /*
2
- * @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
3
- * @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
4
- */
5
- /* eslint-disable no-console, no-var */
6
- import { DateTimeFormatter, ZonedDateTime, ZoneId } from '@js-joda/core';
7
- import '@js-joda/timezone';
8
- import { Locale } from './build/js-joda-locale';
9
-
10
- const zdt = ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneId.of('Europe/Berlin'));
11
- // var zdt = joda.ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('America/Chicago'));
12
- console.log('en_US formatted string:', zdt.format(DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, \'Week \' ww, \'Quarter \' QQQ').withLocale(Locale.US)));
13
- console.log('en_GB formatted string:', zdt.format(DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, \'Week \' ww, \'Quarter \' QQQ').withLocale(Locale.UK)));
14
- console.log('de_DE formatted string:', zdt.format(DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, \'Week \' ww, \'Quarter \' QQQ').withLocale(Locale.GERMANY)));
15
- console.log('fr_FR formatted string:', zdt.format(DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, \'Week \' ww, \'Quarter \' QQQ').withLocale(Locale.FRANCE)));
@@ -1,38 +0,0 @@
1
- /*
2
- * @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
3
- * @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
4
- */
5
- /* eslint-disable no-console, no-var */
6
- const joda = require('@js-joda/core');
7
- require('@js-joda/timezone');
8
-
9
- const {
10
- DateTimeFormatter,
11
- Instant,
12
- ZonedDateTime,
13
- ZoneId,
14
- } = joda;
15
-
16
- const {
17
- Locale,
18
- } = require('./build/js-joda-locale');
19
-
20
-
21
- const zdt = ZonedDateTime.of(2016, 1, 1, 1, 2, 3, 4, ZoneId.of('Europe/Berlin'));
22
- const pattern = 'eeee MMMM dd yyyy GGGG, hh:mm:ss,nnnn a zzzz, \'Week \' ww, \'Quarter \' QQQ';
23
- const enUSFormatter = DateTimeFormatter.ofPattern(pattern).withLocale(Locale.US);
24
- const enGBFormatter = DateTimeFormatter.ofPattern(pattern).withLocale(Locale.UK);
25
- const deDEFormatter = DateTimeFormatter.ofPattern(pattern).withLocale(Locale.GERMANY);
26
- const frFRFormatter = DateTimeFormatter.ofPattern(pattern).withLocale(Locale.FRANCE);
27
- const enUSString = zdt.format(enUSFormatter);
28
- const enGBString = zdt.format(enGBFormatter);
29
- const deDEString = zdt.format(deDEFormatter);
30
- const frFRString = zdt.format(frFRFormatter);
31
- console.log('en_US formatted string:', enUSString);
32
- console.log('en_US string parsed back same Instant as original? ', Instant.from(ZonedDateTime.parse(enUSString, enUSFormatter)).equals(Instant.from(zdt)));
33
- console.log('en_GB formatted string:', enGBString);
34
- console.log('en_GB string parsed back same Instant as original? ', Instant.from(ZonedDateTime.parse(enGBString, enGBFormatter)).equals(Instant.from(zdt)));
35
- console.log('de_DE formatted string:', deDEString);
36
- console.log('en_GB string parsed back same Instant as original? ', Instant.from(ZonedDateTime.parse(deDEString, deDEFormatter)).equals(Instant.from(zdt)));
37
- console.log('fr_FR formatted string:', frFRString);
38
- console.log('en_GB string parsed back same Instant as original? ', Instant.from(ZonedDateTime.parse(frFRString, frFRFormatter)).equals(Instant.from(zdt)));
@@ -1,48 +0,0 @@
1
- /*
2
- * @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
3
- * @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
4
- */
5
- /* eslint-disable no-console, no-var */
6
- var joda = require('@js-joda/core');
7
- require('@js-joda/timezone');
8
-
9
- function outputDateInDifferentLocales(zdt) {
10
- var { Locale } = require('./build/js-joda-locale');
11
- console.log(`Times in ${zdt.zone()}`);
12
- console.log('');
13
- console.log('en_US formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(Locale.US)));
14
- console.log('en_GB formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(Locale.UK)));
15
- console.log('en_CA formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(Locale.CANADA)));
16
- console.log('de_DE formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(Locale.GERMANY)));
17
- console.log('fr_FR formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(Locale.FRANCE)));
18
- console.log('es_ES formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new Locale('es', 'ES', 'es'))));
19
- console.log('ru_RU formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new Locale('ru', 'RU', 'ru'))));
20
- console.log('zh_CN formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new Locale('zh', 'CN', 'zh'))));
21
- console.log('hi_IN formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new Locale('hi', 'IN', 'hi'))));
22
- console.log('-------------------------------------------------------------------');
23
- console.log('');
24
- }
25
-
26
- try {
27
- var { Locale } = require('./build/js-joda-locale');
28
- console.log('locale', Locale);
29
-
30
- console.log(`availableLocales:${JSON.stringify(Locale.getAvailableLocales(), null, 4)}`);
31
-
32
- var zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('Europe/Berlin'));
33
- outputDateInDifferentLocales(zdt);
34
- zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('America/Chicago'));
35
- outputDateInDifferentLocales(zdt);
36
- zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('America/New_York'));
37
- outputDateInDifferentLocales(zdt);
38
- zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('Asia/Hong_Kong'));
39
- outputDateInDifferentLocales(zdt);
40
-
41
- } catch (e) {
42
- console.error(e);
43
- console.error('--------------------------------------------------------------------');
44
- console.error('');
45
- console.error('');
46
- console.error('NOTE: if you see errors about missing modules/locales, you may need to run `npm run build-examples` before using this example.');
47
- process.exit(1);
48
- }
@@ -1,57 +0,0 @@
1
- /*
2
- * @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
3
- * @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
4
- */
5
- const path = require('path');
6
-
7
- // webpack plugin to ignore all cldr-data files not needed for js-joda-locale packages
8
- class CldrDataIgnorePlugin {
9
- constructor(modulesDir, locales) {
10
- this.contextRegex = new RegExp(path.resolve(modulesDir, 'cldr-data'));
11
-
12
- this.requestRegex = [
13
- /^\.\/supplemental\/likelySubtags.json$/,
14
- /^\.\/supplemental\/metaZones.json$/,
15
- /^\.\/supplemental\/weekData.json$/,
16
- /^\.\/availableLocales.json$/,
17
- ];
18
-
19
- locales.forEach((locale) => {
20
- this.requestRegex.push(new RegExp(`^\\.\\/main\\/${locale}\\/ca-gregorian.json$`));
21
- this.requestRegex.push(new RegExp(`^\\.\\/main\\/${locale}\\/timeZoneNames.json$`));
22
- });
23
-
24
- this.checkIgnore = this.checkIgnore.bind(this);
25
- }
26
-
27
- checkIgnore(result) {
28
- if (!result) {
29
- // ignore
30
- return null;
31
- }
32
- if (this.contextRegex.test(result.context)) {
33
- for (let i = 0; i < this.requestRegex.length; i += 1) {
34
- const regex = this.requestRegex[i];
35
- if (regex.test(result.request)) {
36
- // do not ignore
37
- return result;
38
- }
39
- }
40
- // cldr-data but not in requestRegex... so ignore
41
- return null;
42
- }
43
- // do not ignore
44
- return result;
45
- }
46
-
47
- apply(compiler) {
48
- compiler.hooks.normalModuleFactory.tap('CldrDataIgnorePlugin', nmf => {
49
- nmf.hooks.beforeResolve.tap('CldrDataIgnorePlugin', this.checkIgnore);
50
- });
51
- compiler.hooks.contextModuleFactory.tap('CldrDataIgnorePlugin', cmf => {
52
- cmf.hooks.beforeResolve.tap('CldrDataIgnorePlugin', this.checkIgnore);
53
- });
54
- }
55
- }
56
-
57
- module.exports = CldrDataIgnorePlugin;
@@ -1,13 +0,0 @@
1
- # additional date-time classes that complement those in js-joda
2
-
3
- for locale `{{locale}}`
4
-
5
- ## Motivation
6
-
7
- Implementation of locale specific funtionality for js-joda, providing function not implemented in js-joda core
8
-
9
- Especially this implements patterns elements to print and parse locale specific dates
10
-
11
- This package can be used for the `{{locale}}` locales
12
-
13
- for additional info see the main [@js-joda/locale package](https://www.npmjs.com/package/@js-joda/locale)
@@ -1,28 +0,0 @@
1
- /*
2
- * @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
3
- * @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
4
- */
5
- const { DefinePlugin } = require('webpack');
6
-
7
- const CldrDataIgnorePlugin = require('./CldrDataIgnorePlugin');
8
-
9
- function updateWebpackConfigForLocales(webpackConfig, locales, modulesDir) {
10
-
11
- // don't externalize cldrjs and cldr-data
12
- if (webpackConfig.externals) {
13
- delete webpackConfig.externals['cldrjs'];
14
- delete webpackConfig.externals['cldr-data'];
15
- }
16
- // for cldr-data, we only want to include needed files for locales from main and supplemental /
17
- // availableLocales so "exclude" everything else via CldrDataIgnorePlugin
18
- webpackConfig.plugins.push(new CldrDataIgnorePlugin(modulesDir, locales));
19
-
20
- webpackConfig.plugins.push(new DefinePlugin({
21
- JS_JODA_LOCALE_AVAILABLE_LOCALES: JSON.stringify(locales),
22
- }));
23
- return webpackConfig;
24
- }
25
-
26
- module.exports = {
27
- updateWebpackConfigForLocales,
28
- };