@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.
@@ -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 { getCommonFormatsForLocale, buildLocaleFromIntl };
2
+ export default buildLocaleFromIntl;
@@ -262,4 +262,4 @@ const buildLocaleFromIntl = () => {
262
262
  datetime
263
263
  });
264
264
  };
265
- export { getCommonFormatsForLocale, buildLocaleFromIntl };
265
+ export default buildLocaleFromIntl;
@@ -1,5 +1,5 @@
1
1
  import parse from './parse.js';
2
- import { getCommonFormatsForLocale, buildLocaleFromIntl } from './buildLocaleFromIntl.js';
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
- ...common.datetime.map(f => f.pattern),
69
- ...common.date.map(f => f.pattern),
70
- ...common.time.map(f => f.pattern)
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 { buildLocaleFromIntl } from './buildLocaleFromIntl.js';
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): string | true;
19
+ export default function calendar(d: any, wrong_result?: boolean): any;
@@ -1,4 +1,4 @@
1
- import date from '../../date.js';
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 = date(d);
25
+ let r = dt(d);
26
26
  if (!r.isValid) {
27
27
  return wrong_result && isString(wrong_result) ? wrong_result : '';
28
28
  }
@@ -16,4 +16,4 @@
16
16
  * @param {Boolean} dayOnly Whether or not include the time in the date
17
17
  * @returns {String}
18
18
  */
19
- export default function dateSQL(v: any, dayOnly: any): string;
19
+ export default function dateSQL(v: any, dayOnly: any): any;
@@ -1,4 +1,4 @@
1
- import date from '../../date.js';
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 = date(v);
21
+ let value = dt(v);
22
22
  if (value) {
23
23
  return value.format('YYYY-MM-DD' + (dayOnly ? '' : ' HH:mm:ss'));
24
24
  }
@@ -7,4 +7,4 @@
7
7
  * @param {String} wrong_result
8
8
  * @returns
9
9
  */
10
- export default function fdate(d: any, wrong_result?: boolean): string | true;
10
+ export default function fdate(d: any, wrong_result?: boolean): any;
@@ -1,4 +1,4 @@
1
- import date from '../../date.js';
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 = date(d);
13
+ let r = dt(d);
14
14
  let time = false;
15
15
  // Retro compatibility
16
16
  if (wrong_result === true) {
@@ -5,4 +5,4 @@
5
5
  * @memberof bbn.fn
6
6
  * @returns {*}
7
7
  */
8
- export default function fdatetime(d: any, wrong_result?: boolean): string | true;
8
+ export default function fdatetime(d: any, wrong_result?: boolean): any;
@@ -1,4 +1,4 @@
1
- import date from '../../date.js';
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 = date(d);
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): string;
1
+ export default function formatDate(dateToFormat: any, format: any): any;
@@ -1,6 +1,6 @@
1
- import date from '../../date.js';
1
+ import dt from '../../dt.js';
2
2
  export default function formatDate(dateToFormat, format) {
3
- const d = date(dateToFormat);
3
+ const d = dt(dateToFormat);
4
4
  if (!d.isValid) {
5
5
  return '';
6
6
  }
@@ -1,4 +1,4 @@
1
- import date from '../../date.js';
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 = date(d);
11
+ let r = dt(d);
12
12
  if (!r.isValid) {
13
13
  return wrong_result && isString(wrong_result) ? wrong_result : '';
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.91",
3
+ "version": "2.0.93",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",