@bbn/bbn 1.0.474 → 1.0.476

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/date.d.ts CHANGED
@@ -20,6 +20,8 @@ declare class bbnDateTool {
20
20
  get mtst(): number;
21
21
  get YYYY(): string;
22
22
  get YY(): string;
23
+ get MMMM(): string;
24
+ get MMM(): string;
23
25
  get MM(): string;
24
26
  get EE(): string;
25
27
  get DD(): string;
package/dist/date.js CHANGED
@@ -15,6 +15,7 @@ import each from './fn/loop/each.js';
15
15
  import substr from './fn/string/substr.js';
16
16
  import isNumber from './fn/type/isNumber.js';
17
17
  import isDate from './fn/type/isDate.js';
18
+ import isPrimitive from './fn/type/isPrimitive.js';
18
19
  const patterns = [
19
20
  // MariaDB DATETIME "YYYY-MM-DD HH:MM:SS"
20
21
  {
@@ -142,6 +143,8 @@ const unitsCorrespondence = {
142
143
  'Month': 'm',
143
144
  'MONTHS': 'm',
144
145
  'MONTH': 'm',
146
+ 'MMMM': 'm',
147
+ 'MMM': 'm',
145
148
  'MM': 'm',
146
149
  'M': 'm',
147
150
  'm': 'm',
@@ -341,6 +344,20 @@ class bbnDateTool {
341
344
  get YY() {
342
345
  return substr(this.year().toString(), 2, 2);
343
346
  }
347
+ get MMMM() {
348
+ const opt = {
349
+ month: 'long',
350
+ };
351
+ const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
352
+ return d.format(__classPrivateFieldGet(this, _bbnDateTool_value, "f"));
353
+ }
354
+ get MMM() {
355
+ const opt = {
356
+ month: 'short',
357
+ };
358
+ const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
359
+ return d.format(__classPrivateFieldGet(this, _bbnDateTool_value, "f"));
360
+ }
344
361
  get MM() {
345
362
  const m = parseInt(this.month().toString());
346
363
  return m < 10 ? '0' + m.toString() : m.toString();
@@ -474,8 +491,13 @@ class bbnDateTool {
474
491
  return;
475
492
  }
476
493
  if (part in unitsCorrespondence) {
477
- const suffix = formatsMap[unitsCorrespondence[part]];
478
- str += this[suffix];
494
+ if (part in this && isPrimitive(this[part])) {
495
+ str += this[part];
496
+ }
497
+ else {
498
+ const suffix = formatsMap[unitsCorrespondence[part]];
499
+ str += this[suffix];
500
+ }
479
501
  }
480
502
  else {
481
503
  str += part;
@@ -795,6 +817,9 @@ class bbnDateTool {
795
817
  }
796
818
  _bbnDateTool_value = new WeakMap(), _bbnDateTool_daysInMonth = new WeakMap();
797
819
  function generatorFunction(value, inputFormat = null) {
820
+ if (value instanceof bbnDateTool) {
821
+ return value;
822
+ }
798
823
  return new bbnDateTool(value, inputFormat);
799
824
  }
800
825
  export default generatorFunction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.474",
3
+ "version": "1.0.476",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",