@bbn/bbn 1.0.464 → 1.0.466

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,8 +20,12 @@ declare class bbnDateTool {
20
20
  get II(): string;
21
21
  get SS(): string;
22
22
  get WW(): string;
23
+ get isValid(): boolean;
24
+ get daysInMonth(): number;
25
+ get valueOf(): number;
23
26
  add(value: number, unit?: string): bbnDateTool | null;
24
27
  sub(value: number, unit: string | null): bbnDateTool;
28
+ subtract(value: number, unit: string | null): bbnDateTool;
25
29
  dateFromFormat(value: string, unit: string | null): Date;
26
30
  fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
27
31
  ftime(withSeconds?: boolean): string;
@@ -32,7 +36,6 @@ declare class bbnDateTool {
32
36
  * @returns -1 if this < other, 0 if equal, 1 if this > other
33
37
  */
34
38
  compare(date: any, unit?: string): -1 | 0 | 1;
35
- isValid(): boolean;
36
39
  isBefore(date: any, unit?: string): Boolean;
37
40
  isAfter(date: any, unit?: string): Boolean;
38
41
  isSame(date: any, unit?: string): Boolean;
@@ -56,6 +59,7 @@ declare class bbnDateTool {
56
59
  */
57
60
  setWeekday(weekday: any, past: boolean, locale: any): bbnDateTool;
58
61
  copy(): Date;
62
+ clone(): bbnDateTool;
59
63
  /**
60
64
  * Returns a NEW bbnDateTool at the start of the given unit.
61
65
  * Units: year, month, week, day, hour, minute, second
@@ -66,7 +70,6 @@ declare class bbnDateTool {
66
70
  * Units: year, month, week, day, hour, minute, second
67
71
  */
68
72
  endOf(unit?: string): bbnDateTool;
69
- get daysInMonth(): number;
70
73
  }
71
74
  declare function generatorFunction(value: any, inputFormat?: null | String): bbnDateTool;
72
75
  export default generatorFunction;
package/dist/date.js CHANGED
@@ -311,6 +311,37 @@ class bbnDateTool {
311
311
  const pastDaysOfYear = (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime() - firstDayOfYear.getTime()) / 86400000;
312
312
  return String(Math.ceil((pastDaysOfYear + firstDayOfYear.getDay() + 1) / 7)).padStart(2, '0');
313
313
  }
314
+ get isValid() {
315
+ return __classPrivateFieldGet(this, _bbnDateTool_value, "f") !== undefined;
316
+ }
317
+ get daysInMonth() {
318
+ if (this.isValid && !__classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f")) {
319
+ switch (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getMonth()) {
320
+ case 1:
321
+ if (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getFullYear() % 4 === 0) {
322
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 29, "f");
323
+ }
324
+ else {
325
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 28, "f");
326
+ }
327
+ break;
328
+ case 0:
329
+ case 3:
330
+ case 5:
331
+ case 8:
332
+ case 10:
333
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 30, "f");
334
+ break;
335
+ default:
336
+ __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 31, "f");
337
+ break;
338
+ }
339
+ }
340
+ return __classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f");
341
+ }
342
+ get valueOf() {
343
+ return this.mtst;
344
+ }
314
345
  add(value, unit = 'd') {
315
346
  const date = __classPrivateFieldGet(this, _bbnDateTool_value, "f") ? new Date(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime()) : new Date();
316
347
  if (unitsCorrespondence[unit]) {
@@ -326,6 +357,9 @@ class bbnDateTool {
326
357
  sub(value, unit) {
327
358
  return this.add(-value, unit);
328
359
  }
360
+ subtract(value, unit) {
361
+ return this.add(-value, unit);
362
+ }
329
363
  dateFromFormat(value, unit) {
330
364
  const d = new Date();
331
365
  return d;
@@ -429,9 +463,6 @@ class bbnDateTool {
429
463
  }
430
464
  return 0;
431
465
  }
432
- isValid() {
433
- return __classPrivateFieldGet(this, _bbnDateTool_value, "f") !== undefined;
434
- }
435
466
  isBefore(date, unit = '') {
436
467
  return this.compare(date, unit) === -1;
437
468
  }
@@ -604,6 +635,9 @@ class bbnDateTool {
604
635
  copy() {
605
636
  return new Date(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime());
606
637
  }
638
+ clone() {
639
+ return new bbnDateTool(__classPrivateFieldGet(this, _bbnDateTool_value, "f") ? new Date(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime()) : undefined);
640
+ }
607
641
  /**
608
642
  * Returns a NEW bbnDateTool at the start of the given unit.
609
643
  * Units: year, month, week, day, hour, minute, second
@@ -691,31 +725,6 @@ class bbnDateTool {
691
725
  }
692
726
  return new bbnDateTool(d);
693
727
  }
694
- get daysInMonth() {
695
- if (this.isValid && !__classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f")) {
696
- switch (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getMonth()) {
697
- case 1:
698
- if (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getFullYear() % 4 === 0) {
699
- __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 29, "f");
700
- }
701
- else {
702
- __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 28, "f");
703
- }
704
- break;
705
- case 0:
706
- case 3:
707
- case 5:
708
- case 8:
709
- case 10:
710
- __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 30, "f");
711
- break;
712
- default:
713
- __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 31, "f");
714
- break;
715
- }
716
- }
717
- return __classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f");
718
- }
719
728
  }
720
729
  _bbnDateTool_value = new WeakMap(), _bbnDateTool_daysInMonth = new WeakMap();
721
730
  function generatorFunction(value, inputFormat = null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.464",
3
+ "version": "1.0.466",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",