@bbn/bbn 1.0.444 → 1.0.445
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/date.d.ts +1 -0
- package/dist/date.js +12 -46
- package/package.json +1 -1
package/dist/date.d.ts
CHANGED
package/dist/date.js
CHANGED
|
@@ -102,6 +102,14 @@ const unitsMap = {
|
|
|
102
102
|
'n': 'Minutes',
|
|
103
103
|
's': 'Seconds'
|
|
104
104
|
};
|
|
105
|
+
const formatsMap = {
|
|
106
|
+
'y': 'YYYY',
|
|
107
|
+
'm': 'MM',
|
|
108
|
+
'd': 'DD',
|
|
109
|
+
'h': 'HH',
|
|
110
|
+
'n': 'mm',
|
|
111
|
+
's': 'ss'
|
|
112
|
+
};
|
|
105
113
|
const unitsCorrespondence = {
|
|
106
114
|
'YYYY': 'y',
|
|
107
115
|
'YY': 'y',
|
|
@@ -210,6 +218,9 @@ class bbnDateTool {
|
|
|
210
218
|
get seconds() {
|
|
211
219
|
return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getSeconds();
|
|
212
220
|
}
|
|
221
|
+
get weekday() {
|
|
222
|
+
return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getDay();
|
|
223
|
+
}
|
|
213
224
|
get tst() {
|
|
214
225
|
return Math.ceil(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime() / 1000);
|
|
215
226
|
}
|
|
@@ -263,7 +274,7 @@ class bbnDateTool {
|
|
|
263
274
|
const parts = format.split(reg);
|
|
264
275
|
each(parts, (part) => {
|
|
265
276
|
if (part in unitsCorrespondence) {
|
|
266
|
-
const suffix =
|
|
277
|
+
const suffix = formatsMap[unitsCorrespondence[part]];
|
|
267
278
|
str += this[suffix];
|
|
268
279
|
}
|
|
269
280
|
else {
|
|
@@ -335,51 +346,6 @@ class bbnDateTool {
|
|
|
335
346
|
isBeforeOrSame(date, unit = '') {
|
|
336
347
|
return [-1, 0].includes(this.compare(date, unit));
|
|
337
348
|
}
|
|
338
|
-
/*
|
|
339
|
-
const d = new bbnDateTool(date);
|
|
340
|
-
if (unitsCorrespondence[unit]) {
|
|
341
|
-
const realUnit = unitsCorrespondence[unit];
|
|
342
|
-
switch (realUnit) {
|
|
343
|
-
case 'y':
|
|
344
|
-
return this.year < d.year;
|
|
345
|
-
case 'm':
|
|
346
|
-
return (this.year < d.year) || (this.year === d.year && this.month < d.month);
|
|
347
|
-
case 'd':
|
|
348
|
-
return (this.year < d.year) || (this.year === d.year && this.month < d.month) || (this.year === d.year && this.month === d.month && this.day < d.day);
|
|
349
|
-
case 'h':
|
|
350
|
-
return (this.year < d.year) || (this.year === d.year && this.month < d.month) || (this.year === d.year && this.month === d.month && this.day < d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours < d.hours);
|
|
351
|
-
case 'n':
|
|
352
|
-
return (this.year < d.year) || (this.year === d.year && this.month < d.month) || (this.year === d.year && this.month === d.month && this.day < d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours < d.hours) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes < d.minutes);
|
|
353
|
-
case 's':
|
|
354
|
-
return (this.year < d.year) || (this.year === d.year && this.month < d.month) || (this.year === d.year && this.month === d.month && this.day < d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours < d.hours) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes < d.minutes) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes === d.minutes && this.seconds < d.seconds);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return this.mtst < d.mtst;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
isBeforeOrSame(date: any, unit: string = ''): Boolean {
|
|
362
|
-
const d = new bbnDateTool(date);
|
|
363
|
-
if (unitsCorrespondence[unit]) {
|
|
364
|
-
const realUnit = unitsCorrespondence[unit];
|
|
365
|
-
switch (realUnit) {
|
|
366
|
-
case 'y':
|
|
367
|
-
return this.year <= d.year;
|
|
368
|
-
case 'm':
|
|
369
|
-
return (this.year <= d.year) || (this.year === d.year && this.month <= d.month);
|
|
370
|
-
case 'd':
|
|
371
|
-
return (this.year <= d.year) || (this.year === d.year && this.month <= d.month) || (this.year === d.year && this.month === d.month && this.day <= d.day);
|
|
372
|
-
case 'h':
|
|
373
|
-
return (this.year <= d.year) || (this.year === d.year && this.month <= d.month) || (this.year === d.year && this.month === d.month && this.day <= d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours <= d.hours);
|
|
374
|
-
case 'n':
|
|
375
|
-
return (this.year <= d.year) || (this.year === d.year && this.month <= d.month) || (this.year === d.year && this.month === d.month && this.day <= d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours <= d.hours) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes <= d.minutes);
|
|
376
|
-
case 's':
|
|
377
|
-
return (this.year <= d.year) || (this.year === d.year && this.month <= d.month) || (this.year === d.year && this.month === d.month && this.day <= d.day) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours <= d.hours) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes <= d.minutes) || (this.year === d.year && this.month === d.month && this.day === d.day && this.hours === d.hours && this.minutes === d.minutes && this.seconds <= d.seconds);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
return this.mtst < d.mtst;
|
|
382
|
-
}*/
|
|
383
349
|
calendar(format) {
|
|
384
350
|
let str = '';
|
|
385
351
|
if (format) {
|