@bbn/bbn 2.0.91 → 2.0.93
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/dist/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/dt/functions/buildLocaleFromIntl.d.ts +1 -28
- package/dist/dt/functions/buildLocaleFromIntl.js +1 -1
- package/dist/dt/functions/guessFormat.js +4 -6
- package/dist/dt/functions/parse.js +1 -1
- package/dist/fn/datetime/calendar.d.ts +1 -1
- package/dist/fn/datetime/calendar.js +2 -2
- package/dist/fn/datetime/dateSQL.d.ts +1 -1
- package/dist/fn/datetime/dateSQL.js +2 -2
- package/dist/fn/datetime/fdate.d.ts +1 -1
- package/dist/fn/datetime/fdate.js +2 -2
- package/dist/fn/datetime/fdatetime.d.ts +1 -1
- package/dist/fn/datetime/fdatetime.js +2 -2
- package/dist/fn/datetime/formatDate.d.ts +1 -1
- package/dist/fn/datetime/formatDate.js +2 -2
- package/dist/fn/datetime/ftime.js +2 -2
- package/package.json +1 -1
|
@@ -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';
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
* @param {String | Boolean} wrong_result Whether or not include the time in the date
|
|
17
17
|
* @returns {String}
|
|
18
18
|
*/
|
|
19
|
-
export default function calendar(d: any, wrong_result?: boolean):
|
|
19
|
+
export default function calendar(d: any, wrong_result?: boolean): any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dt from '../../dt.js';
|
|
2
2
|
import isString from '../type/isString.js';
|
|
3
3
|
const bbn = {
|
|
4
4
|
_: st => st
|
|
@@ -22,7 +22,7 @@ const bbn = {
|
|
|
22
22
|
* @returns {String}
|
|
23
23
|
*/
|
|
24
24
|
export default function calendar(d, wrong_result = false) {
|
|
25
|
-
let r =
|
|
25
|
+
let r = dt(d);
|
|
26
26
|
if (!r.isValid) {
|
|
27
27
|
return wrong_result && isString(wrong_result) ? wrong_result : '';
|
|
28
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dt from '../../dt.js';
|
|
2
2
|
/**
|
|
3
3
|
* Returns a date with SQL format.
|
|
4
4
|
*
|
|
@@ -18,7 +18,7 @@ import date from '../../date.js';
|
|
|
18
18
|
* @returns {String}
|
|
19
19
|
*/
|
|
20
20
|
export default function dateSQL(v, dayOnly) {
|
|
21
|
-
let value =
|
|
21
|
+
let value = dt(v);
|
|
22
22
|
if (value) {
|
|
23
23
|
return value.format('YYYY-MM-DD' + (dayOnly ? '' : ' HH:mm:ss'));
|
|
24
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dt from '../../dt.js';
|
|
2
2
|
import isString from '../type/isString.js';
|
|
3
3
|
/**
|
|
4
4
|
* @method fdate
|
|
@@ -10,7 +10,7 @@ import isString from '../type/isString.js';
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
export default function fdate(d, wrong_result = false) {
|
|
13
|
-
let r =
|
|
13
|
+
let r = dt(d);
|
|
14
14
|
let time = false;
|
|
15
15
|
// Retro compatibility
|
|
16
16
|
if (wrong_result === true) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dt from '../../dt.js';
|
|
2
2
|
import isString from '../type/isString.js';
|
|
3
3
|
/**
|
|
4
4
|
* @method fdatetime
|
|
@@ -8,7 +8,7 @@ import isString from '../type/isString.js';
|
|
|
8
8
|
* @returns {*}
|
|
9
9
|
*/
|
|
10
10
|
export default function fdatetime(d, wrong_result = false) {
|
|
11
|
-
let r =
|
|
11
|
+
let r = dt(d);
|
|
12
12
|
if (!r.isValid) {
|
|
13
13
|
return wrong_result && isString(wrong_result) ? wrong_result : '';
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function formatDate(dateToFormat: any, format: any):
|
|
1
|
+
export default function formatDate(dateToFormat: any, format: any): any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dt from '../../dt.js';
|
|
2
2
|
import isString from '../type/isString.js';
|
|
3
3
|
/**
|
|
4
4
|
* @method ftime
|
|
@@ -8,7 +8,7 @@ import isString from '../type/isString.js';
|
|
|
8
8
|
* @returns {*}
|
|
9
9
|
*/
|
|
10
10
|
export default function ftime(d, wrong_result) {
|
|
11
|
-
let r =
|
|
11
|
+
let r = dt(d);
|
|
12
12
|
if (!r.isValid) {
|
|
13
13
|
return wrong_result && isString(wrong_result) ? wrong_result : '';
|
|
14
14
|
}
|