@bbn/bbn 2.0.2 → 2.0.4

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
@@ -38,7 +38,8 @@ declare class bbnDateTool {
38
38
  get S(): string;
39
39
  get WW(): string;
40
40
  get isValid(): boolean;
41
- get daysInMonth(): number;
41
+ inLeapYear(): boolean;
42
+ daysInMonth(): number;
42
43
  valueOf(): number;
43
44
  add(value: number, unit?: string): bbnDateTool | null;
44
45
  subtract(value: number, unit?: string): bbnDateTool;
package/dist/date.js CHANGED
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _bbnDateDuration_instances, _bbnDateDuration_durationMs, _bbnDateDuration_unit, _bbnDateDuration_getUnitRowByName, _bbnDateDuration_getUnitValue, _bbnDateTool_value, _bbnDateTool_daysInMonth, _bbnDateTool_isDuration;
12
+ var _bbnDateDuration_instances, _bbnDateDuration_durationMs, _bbnDateDuration_unit, _bbnDateDuration_getUnitRowByName, _bbnDateDuration_getUnitValue, _bbnDateTool_value, _bbnDateTool_isDuration;
13
13
  import _ from './_.js';
14
14
  import each from './fn/loop/each.js';
15
15
  import substr from './fn/string/substr.js';
@@ -314,7 +314,6 @@ _bbnDateDuration_durationMs = new WeakMap(), _bbnDateDuration_unit = new WeakMap
314
314
  class bbnDateTool {
315
315
  constructor(value, inputFormat = null) {
316
316
  _bbnDateTool_value.set(this, void 0);
317
- _bbnDateTool_daysInMonth.set(this, 0);
318
317
  _bbnDateTool_isDuration.set(this, false);
319
318
  let t = typeof value;
320
319
  if (!value) {
@@ -531,30 +530,33 @@ class bbnDateTool {
531
530
  get isValid() {
532
531
  return __classPrivateFieldGet(this, _bbnDateTool_value, "f") !== undefined;
533
532
  }
534
- get daysInMonth() {
535
- if (this.isValid && !__classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f")) {
533
+ inLeapYear() {
534
+ if (this.isValid) {
535
+ const year = __classPrivateFieldGet(this, _bbnDateTool_value, "f").getFullYear();
536
+ return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
537
+ }
538
+ return false;
539
+ }
540
+ daysInMonth() {
541
+ if (this.isValid) {
536
542
  switch (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getMonth()) {
537
543
  case 1:
538
544
  if (__classPrivateFieldGet(this, _bbnDateTool_value, "f").getFullYear() % 4 === 0) {
539
- __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 29, "f");
545
+ return 29;
540
546
  }
541
547
  else {
542
- __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 28, "f");
548
+ return 28;
543
549
  }
544
- break;
545
550
  case 0:
546
551
  case 3:
547
552
  case 5:
548
553
  case 8:
549
554
  case 10:
550
- __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 30, "f");
551
- break;
555
+ return 30;
552
556
  default:
553
- __classPrivateFieldSet(this, _bbnDateTool_daysInMonth, 31, "f");
554
- break;
557
+ return 31;
555
558
  }
556
559
  }
557
- return __classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f");
558
560
  }
559
561
  valueOf() {
560
562
  return this.mtst;
@@ -609,7 +611,7 @@ class bbnDateTool {
609
611
  const t = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
610
612
  return t.format(__classPrivateFieldGet(this, _bbnDateTool_value, "f"));
611
613
  }
612
- format(format = 'y-m-d h:i:s') {
614
+ format(format = 'YYYY-MM-DD HH:II:SS') {
613
615
  let str = '';
614
616
  if (format) {
615
617
  const reg = new RegExp('(\[|\]|' + Object.keys(unitsCorrespondence).join('|') + ')', 'g');
@@ -969,7 +971,7 @@ class bbnDateTool {
969
971
  return new bbnDateDuration(num, unit);
970
972
  }
971
973
  }
972
- _bbnDateTool_value = new WeakMap(), _bbnDateTool_daysInMonth = new WeakMap(), _bbnDateTool_isDuration = new WeakMap();
974
+ _bbnDateTool_value = new WeakMap(), _bbnDateTool_isDuration = new WeakMap();
973
975
  function generatorFunction(value, inputFormat = null) {
974
976
  if (value instanceof bbnDateTool) {
975
977
  return value;
package/dist/fn.d.ts CHANGED
@@ -42,7 +42,6 @@ import cssExists from './fn/style/cssExists.js';
42
42
  import data2Html from './fn/string/data2Html.js';
43
43
  import date from './fn/datetime/date.js';
44
44
  import dateSQL from './fn/datetime/dateSQL.js';
45
- import daysInMonth from './fn/datetime/daysInMonth.js';
46
45
  import deepPath from './fn/object/deepPath.js';
47
46
  import defaultAjaxAbortFunction from './fn/default/defaultAjaxAbortFunction.js';
48
47
  import defaultAjaxErrorFunction from './fn/default/defaultAjaxErrorFunction.js';
@@ -290,7 +289,6 @@ declare const _default: {
290
289
  data2Html: typeof data2Html;
291
290
  date: typeof date;
292
291
  dateSQL: typeof dateSQL;
293
- daysInMonth: typeof daysInMonth;
294
292
  deepPath: typeof deepPath;
295
293
  defaultAjaxAbortFunction: typeof defaultAjaxAbortFunction;
296
294
  defaultAjaxErrorFunction: typeof defaultAjaxErrorFunction;
package/dist/fn.js CHANGED
@@ -42,7 +42,6 @@ import cssExists from './fn/style/cssExists.js';
42
42
  import data2Html from './fn/string/data2Html.js';
43
43
  import date from './fn/datetime/date.js';
44
44
  import dateSQL from './fn/datetime/dateSQL.js';
45
- import daysInMonth from './fn/datetime/daysInMonth.js';
46
45
  import deepPath from './fn/object/deepPath.js';
47
46
  import defaultAjaxAbortFunction from './fn/default/defaultAjaxAbortFunction.js';
48
47
  import defaultAjaxErrorFunction from './fn/default/defaultAjaxErrorFunction.js';
@@ -290,7 +289,6 @@ export default {
290
289
  data2Html,
291
290
  date,
292
291
  dateSQL,
293
- daysInMonth,
294
292
  deepPath,
295
293
  defaultAjaxAbortFunction,
296
294
  defaultAjaxErrorFunction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,16 +0,0 @@
1
- /**
2
- * Returns the number of days of the month given in the date.
3
- * @method daysInMonth
4
- * @global
5
- *
6
- * @example
7
- * ``` javascript
8
- * //30
9
- * bbn.fn.daysInMonth(new Date());
10
- * ```
11
- *
12
- * @memberof bbn.fn
13
- * @param {String|Date} v
14
- * @returns {Number}
15
- */
16
- export default function daysInMonth(v: any): number;
@@ -1,21 +0,0 @@
1
- import date from '../../date.js';
2
- /**
3
- * Returns the number of days of the month given in the date.
4
- * @method daysInMonth
5
- * @global
6
- *
7
- * @example
8
- * ``` javascript
9
- * //30
10
- * bbn.fn.daysInMonth(new Date());
11
- * ```
12
- *
13
- * @memberof bbn.fn
14
- * @param {String|Date} v
15
- * @returns {Number}
16
- */
17
- export default function daysInMonth(v) {
18
- let d = date(v);
19
- return d.daysInMonth;
20
- }
21
- ;