@bbn/bbn 2.0.36 → 2.0.37

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.
@@ -23,12 +23,6 @@ type CommonFormats = {
23
23
  * - Date: only sensible combos (Y-M-D ± weekday, Y-M, M-D).
24
24
  * - Time: hour / hour:minute / hour:minute:second (+ optional TZ).
25
25
  * - Datetime: only full dates (Y-M-D ± weekday) combined with time.
26
- *
27
- * Fully numeric date forms (like "1/1/1970") are explicitly included via:
28
- * { year: 'numeric', month: 'numeric', day: 'numeric' }
29
- * { year: '2-digit', month: 'numeric', day: 'numeric' }
30
- * { year: 'numeric', month: '2-digit', day: '2-digit' }
31
- * { year: '2-digit', month: '2-digit', day: '2-digit' }
32
26
  */
33
27
  export declare function getCommonFormatsForLocale(lng: string | string[]): CommonFormats;
34
28
  export default function buildLocaleFromIntl(): void;
@@ -3,8 +3,6 @@ import numProperties from "../../fn/object/numProperties.js";
3
3
  /**
4
4
  * Build a token pattern (YYYY, MM, DD, dddd, HH, II, SS, A, z) from Intl parts.
5
5
  * Uses Intl options to distinguish MMM vs MMMM, ddd vs dddd, etc.
6
- * All literal chunks are wrapped in square brackets so they can't be mistaken
7
- * for tokens by the parser.
8
6
  */
9
7
  function partsToPattern(parts, hourCycle, opts) {
10
8
  let pattern = '';
@@ -23,11 +21,10 @@ function partsToPattern(parts, hourCycle, opts) {
23
21
  pattern += 'MMMM';
24
22
  }
25
23
  else if (opts.month === 'numeric' || opts.month === '2-digit') {
26
- // numeric month
27
24
  pattern += /^\d{2}$/.test(p.value) ? 'MM' : 'M';
28
25
  }
29
26
  else {
30
- // Fallback: infer from value
27
+ // Fallback
31
28
  if (/^\d+$/.test(p.value)) {
32
29
  pattern += p.value.length === 2 ? 'MM' : 'M';
33
30
  }
@@ -70,16 +67,8 @@ function partsToPattern(parts, hourCycle, opts) {
70
67
  case 'timeZoneName':
71
68
  pattern += 'z';
72
69
  break;
73
- case 'literal': {
74
- // Wrap ALL literals into [ ... ] to avoid confusion with tokens
75
- if (p.value.length) {
76
- const v = p.value.replace(/]/g, '\\]');
77
- pattern += `[${v}]`;
78
- }
79
- break;
80
- }
70
+ case 'literal':
81
71
  default:
82
- // Fallback, should be rare
83
72
  pattern += p.value;
84
73
  break;
85
74
  }
@@ -94,12 +83,6 @@ function partsToPattern(parts, hourCycle, opts) {
94
83
  * - Date: only sensible combos (Y-M-D ± weekday, Y-M, M-D).
95
84
  * - Time: hour / hour:minute / hour:minute:second (+ optional TZ).
96
85
  * - Datetime: only full dates (Y-M-D ± weekday) combined with time.
97
- *
98
- * Fully numeric date forms (like "1/1/1970") are explicitly included via:
99
- * { year: 'numeric', month: 'numeric', day: 'numeric' }
100
- * { year: '2-digit', month: 'numeric', day: 'numeric' }
101
- * { year: 'numeric', month: '2-digit', day: '2-digit' }
102
- * { year: '2-digit', month: '2-digit', day: '2-digit' }
103
86
  */
104
87
  export function getCommonFormatsForLocale(lng) {
105
88
  const sample = new Date(Date.UTC(2000, 0, 2, 13, 45, 30));
@@ -110,14 +93,11 @@ export function getCommonFormatsForLocale(lng) {
110
93
  const seenTimePatterns = new Set();
111
94
  const seenDateTimePatterns = new Set();
112
95
  // ---- 1) DATE: curated list of useful patterns ----
113
- // Numeric full dates (this covers "1/1/1970"-style formats as masks like D/M/YYYY or DD/MM/YYYY).
96
+ // Includes your important one: { day: "numeric", month: "short", year: "numeric" }
114
97
  const dateOptionsList = [
115
- // Fully numeric YYYY-M-D variants
116
- { year: 'numeric', month: 'numeric', day: 'numeric' },
98
+ // Full dates
117
99
  { year: 'numeric', month: '2-digit', day: '2-digit' },
118
- { year: '2-digit', month: 'numeric', day: 'numeric' },
119
- { year: '2-digit', month: '2-digit', day: '2-digit' },
120
- // Full dates with textual month
100
+ { year: 'numeric', month: 'numeric', day: 'numeric' },
121
101
  { year: 'numeric', month: 'short', day: 'numeric' },
122
102
  { year: 'numeric', month: 'long', day: 'numeric' },
123
103
  // Full dates with weekday
@@ -131,7 +111,7 @@ export function getCommonFormatsForLocale(lng) {
131
111
  // Month–day (no year)
132
112
  { month: 'numeric', day: 'numeric' },
133
113
  { month: '2-digit', day: '2-digit' },
134
- { month: 'short', day: 'numeric' },
114
+ { month: 'short', day: 'numeric' }, // ← e.g. "22 janv."
135
115
  { month: 'long', day: 'numeric' }
136
116
  ];
137
117
  const fullDateOptions = []; // Y+M+D (± weekday)
@@ -176,7 +156,7 @@ export function getCommonFormatsForLocale(lng) {
176
156
  });
177
157
  }
178
158
  }
179
- // ---- 3) DATETIME: only full dates (Y-M-D ± weekday) × time ----
159
+ // ---- 3) DATETIME: only full dates (Y-M-D ± weekday) × time
180
160
  for (const dOpts of fullDateOptions) {
181
161
  for (const tOpts of timeOptionsList) {
182
162
  const opts = Object.assign(Object.assign({}, dOpts), tOpts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.36",
3
+ "version": "2.0.37",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",