@bbn/bbn 2.0.91 → 2.0.92
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.
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
type CommonFormats = {
|
|
2
|
-
date: Array<{
|
|
3
|
-
pattern: string;
|
|
4
|
-
sample: string;
|
|
5
|
-
options: Intl.DateTimeFormatOptions;
|
|
6
|
-
}>;
|
|
7
|
-
time: Array<{
|
|
8
|
-
pattern: string;
|
|
9
|
-
sample: string;
|
|
10
|
-
options: Intl.DateTimeFormatOptions;
|
|
11
|
-
}>;
|
|
12
|
-
datetime: Array<{
|
|
13
|
-
pattern: string;
|
|
14
|
-
sample: string;
|
|
15
|
-
options: Intl.DateTimeFormatOptions;
|
|
16
|
-
}>;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Get a curated set of *common* date, time and datetime formats
|
|
20
|
-
* for the given locale, without exploding into thousands of combos.
|
|
21
|
-
*
|
|
22
|
-
* Rules:
|
|
23
|
-
* - Date: only sensible combos (Y-M-D ± weekday, Y-M, M-D).
|
|
24
|
-
* - Time: hour / hour:minute / hour:minute:second (+ optional TZ).
|
|
25
|
-
* - Datetime: only full dates (Y-M-D ± weekday) combined with time.
|
|
26
|
-
*/
|
|
27
|
-
declare const getCommonFormatsForLocale: (lng?: string | string[]) => CommonFormats;
|
|
28
1
|
declare const buildLocaleFromIntl: () => void;
|
|
29
|
-
export
|
|
2
|
+
export default buildLocaleFromIntl;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import parse from './parse.js';
|
|
2
|
-
import
|
|
2
|
+
import buildLocaleFromIntl from './buildLocaleFromIntl.js';
|
|
3
3
|
// Common MySQL & native JS string formats – tried first in guessFormat
|
|
4
4
|
const MYSQL_AND_NATIVE_FORMATS = [
|
|
5
5
|
// --- MySQL / MariaDB classic ---
|
|
@@ -54,8 +54,6 @@ export default function guessFormat(input, formats, lng) {
|
|
|
54
54
|
const list = Array.isArray(formats) ? formats : [formats];
|
|
55
55
|
return tryFormats(list);
|
|
56
56
|
}
|
|
57
|
-
// autodetect via Intl-derived formats
|
|
58
|
-
const common = getCommonFormatsForLocale(lng);
|
|
59
57
|
// Avoid trivial duplicates
|
|
60
58
|
const seen = new Set();
|
|
61
59
|
const mysqlNativeCandidates = MYSQL_AND_NATIVE_FORMATS.filter(fmt => {
|
|
@@ -65,9 +63,9 @@ export default function guessFormat(input, formats, lng) {
|
|
|
65
63
|
return true;
|
|
66
64
|
});
|
|
67
65
|
const localeCandidates = [
|
|
68
|
-
...
|
|
69
|
-
...
|
|
70
|
-
...
|
|
66
|
+
...bbn.dt.locales.datetime.map(f => f.pattern),
|
|
67
|
+
...bbn.dt.locales.date.map(f => f.pattern),
|
|
68
|
+
...bbn.dt.locales.time.map(f => f.pattern)
|
|
71
69
|
].filter(fmt => {
|
|
72
70
|
if (seen.has(fmt))
|
|
73
71
|
return false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import buildLocaleFromIntl from './buildLocaleFromIntl.js';
|
|
2
2
|
import bbnDtZoned from '../classes/zoned.js';
|
|
3
3
|
import bbnDtDateTime from '../classes/dateTime.js';
|
|
4
4
|
import bbnDtDate from '../classes/date.js';
|