cldr 7.8.0 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
+ ### v7.9.0 (2025-04-08)
2
+
3
+ - [#182](https://github.com/papandreou/node-cldr/pull/182) Adding dayPeriodPatterns ([Andreas Lind](mailto:andreaslindpetersen@gmail.com), [rotsee](mailto:leo_wallentin@hotmail.com))
4
+
1
5
  ### v7.8.0 (2025-04-01)
2
6
 
7
+ - [#181](https://github.com/papandreou/node-cldr/pull/181) CLDR 47 ([rotsee](mailto:leo_wallentin@hotmail.com))
8
+
9
+ ### v7.7.0 (2025-01-26)
10
+
3
11
  #### Pull requests
4
12
 
5
- - [#181](https://github.com/papandreou/node-cldr/pull/181) CLDR 47 ([rotsee](mailto:leo_wallentin@hotmail.com))
6
13
  - [#180](https://github.com/papandreou/node-cldr/pull/180) CLDR 46 data update ([rotsee](mailto:leo_wallentin@hotmail.com))
7
14
 
8
15
  #### Commits to master
9
16
 
17
+ - [Revert "7.7.0"](https://github.com/papandreou/node-cldr/commit/9e15e2673aacaa7a239c0c89da1b20214cd1ef77) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com))
10
18
  - [Update CI config to not run on node.js <= 12, add node.js 18-22, drive-by update to ubuntu-latest](https://github.com/papandreou/node-cldr/commit/94eef6bccf355db2a73b8bcb65a76867ba86edb3) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com))
11
19
  - [xmldom security vuln patch](https://github.com/papandreou/node-cldr/commit/befdf269f185ab67daa5efadc5dc1c50099879e0) ([rotsee](mailto:leo_wallentin@hotmail.com))
12
20
  - [prettier linting](https://github.com/papandreou/node-cldr/commit/1cdd24625fc06300eabb9bc916464bbab29c4f42) ([rotsee](mailto:leo_wallentin@hotmail.com))
package/README.md CHANGED
@@ -453,6 +453,28 @@ cldr.extractDayPeriods('en_GB', 'gregorian');
453
453
  wide: { am: 'AM', pm: 'PM' } } }
454
454
  ```
455
455
 
456
+ ### cldr.extractDayPeriodRules(localeId='root')
457
+
458
+ Extract a ruleset for locale-aware day periods,
459
+ to be used with extractDayPeriods().
460
+
461
+ ```javascript
462
+ cldr.extractDayPeriodRules('nl');
463
+ { format: [
464
+ { type: 'morning1', at: '', from: '06:00', before: '12:00' },
465
+ { type: 'afternoon1', at: '', from: '12:00', before: '18:00' },
466
+ { type: 'evening1', at: '', from: '18:00', before: '24:00' },
467
+ { type: 'night1', at: '', from: '00:00', before: '06:00' },
468
+ ],
469
+ standAlone: [
470
+ { type: 'midnight', at: '00:00', from: '', before: '' },
471
+ { type: 'morning1', at: '', from: '06:00', before: '12:00' },
472
+ { type: 'afternoon1', at: '', from: '12:00', before: '18:00' },
473
+ { type: 'evening1', at: '', from: '18:00', before: '24:00' },
474
+ { type: 'night1', at: '', from: '00:00', before: '06:00' }
475
+ ] }
476
+ ```
477
+
456
478
  ### cldr.extractCyclicNames(localeId='root', calendarId='gregorian')
457
479
 
458
480
  Extract a nested hash with cyclic names for a calendar and locale
package/lib/cldr.js CHANGED
@@ -838,6 +838,47 @@ Cldr.prototype = {
838
838
  return dayPeriods;
839
839
  },
840
840
 
841
+ extractDayPeriodRules(localeId) {
842
+ this.checkValidLocaleId(localeId);
843
+ const document = this.getDocument(
844
+ Path.resolve(this.cldrPath, 'common', 'supplemental', 'dayPeriods.xml'),
845
+ );
846
+ const dayPeriodRulesNode = xpath.select1(
847
+ '/supplementalData/dayPeriodRuleSet[not(@type)]' +
848
+ `/dayPeriodRules[@locales='${localeId}']`,
849
+ document,
850
+ );
851
+ const dayPeriodRules = xpath.select('dayPeriodRule', dayPeriodRulesNode);
852
+
853
+ const dayPeriodRulesSelectNode = xpath.select1(
854
+ "/supplementalData/dayPeriodRuleSet[@type='selection']" +
855
+ `/dayPeriodRules[@locales='${localeId}']`,
856
+ document,
857
+ );
858
+ const dayPeriodSelectsRules = xpath.select(
859
+ 'dayPeriodRule',
860
+ dayPeriodRulesSelectNode,
861
+ );
862
+ return {
863
+ standAlone: dayPeriodRules.map((dayPeriodRuleNode) => {
864
+ return {
865
+ type: dayPeriodRuleNode.getAttribute('type'),
866
+ at: dayPeriodRuleNode.getAttribute('at'),
867
+ from: dayPeriodRuleNode.getAttribute('from'),
868
+ before: dayPeriodRuleNode.getAttribute('before'),
869
+ };
870
+ }),
871
+ format: dayPeriodSelectsRules.map((dayPeriodRuleNode) => {
872
+ return {
873
+ type: dayPeriodRuleNode.getAttribute('type'),
874
+ at: dayPeriodRuleNode.getAttribute('at'),
875
+ from: dayPeriodRuleNode.getAttribute('from'),
876
+ before: dayPeriodRuleNode.getAttribute('before'),
877
+ };
878
+ }),
879
+ };
880
+ },
881
+
841
882
  extractCyclicNames(localeId, calendarId) {
842
883
  this.checkValidLocaleId(localeId);
843
884
  calendarId = calendarId || 'gregorian';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cldr",
3
- "version": "7.8.0",
3
+ "version": "7.9.0",
4
4
  "description": "Library for extracting data from CLDR (the Unicode Common Locale Data Repository)",
5
5
  "main": "lib/cldr.js",
6
6
  "scripts": {
@@ -0,0 +1,22 @@
1
+ const expect = require('unexpected');
2
+
3
+ const cldr = require('../lib/cldr');
4
+
5
+ describe('extractDayPeriodRules', () => {
6
+ const dutchDayPeriodRules = cldr.extractDayPeriodRules('nl');
7
+ it('should have the correct rules', () => {
8
+ expect(dutchDayPeriodRules.standAlone, 'to equal', [
9
+ { type: 'midnight', at: '00:00', from: '', before: '' },
10
+ { type: 'morning1', at: '', from: '06:00', before: '12:00' },
11
+ { type: 'afternoon1', at: '', from: '12:00', before: '18:00' },
12
+ { type: 'evening1', at: '', from: '18:00', before: '24:00' },
13
+ { type: 'night1', at: '', from: '00:00', before: '06:00' },
14
+ ]);
15
+ expect(dutchDayPeriodRules.format, 'to equal', [
16
+ { type: 'morning1', at: '', from: '06:00', before: '12:00' },
17
+ { type: 'afternoon1', at: '', from: '12:00', before: '18:00' },
18
+ { type: 'evening1', at: '', from: '18:00', before: '24:00' },
19
+ { type: 'night1', at: '', from: '00:00', before: '06:00' },
20
+ ]);
21
+ });
22
+ });