@bbn/bbn 1.0.443 → 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 +15 -48
- 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
|
}
|
|
@@ -256,13 +267,14 @@ class bbnDateTool {
|
|
|
256
267
|
const d = new Date();
|
|
257
268
|
return d;
|
|
258
269
|
}
|
|
259
|
-
format(format = '') {
|
|
270
|
+
format(format = 'y-m-d h:n:s') {
|
|
260
271
|
let str = '';
|
|
261
272
|
if (format) {
|
|
262
|
-
const
|
|
273
|
+
const reg = new RegExp('(' + Object.keys(unitsCorrespondence).join('|') + ')', 'g');
|
|
274
|
+
const parts = format.split(reg);
|
|
263
275
|
each(parts, (part) => {
|
|
264
276
|
if (part in unitsCorrespondence) {
|
|
265
|
-
const suffix =
|
|
277
|
+
const suffix = formatsMap[unitsCorrespondence[part]];
|
|
266
278
|
str += this[suffix];
|
|
267
279
|
}
|
|
268
280
|
else {
|
|
@@ -334,51 +346,6 @@ class bbnDateTool {
|
|
|
334
346
|
isBeforeOrSame(date, unit = '') {
|
|
335
347
|
return [-1, 0].includes(this.compare(date, unit));
|
|
336
348
|
}
|
|
337
|
-
/*
|
|
338
|
-
const d = new bbnDateTool(date);
|
|
339
|
-
if (unitsCorrespondence[unit]) {
|
|
340
|
-
const realUnit = unitsCorrespondence[unit];
|
|
341
|
-
switch (realUnit) {
|
|
342
|
-
case 'y':
|
|
343
|
-
return this.year < d.year;
|
|
344
|
-
case 'm':
|
|
345
|
-
return (this.year < d.year) || (this.year === d.year && this.month < d.month);
|
|
346
|
-
case 'd':
|
|
347
|
-
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);
|
|
348
|
-
case 'h':
|
|
349
|
-
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);
|
|
350
|
-
case 'n':
|
|
351
|
-
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);
|
|
352
|
-
case 's':
|
|
353
|
-
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);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
return this.mtst < d.mtst;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
isBeforeOrSame(date: any, unit: string = ''): Boolean {
|
|
361
|
-
const d = new bbnDateTool(date);
|
|
362
|
-
if (unitsCorrespondence[unit]) {
|
|
363
|
-
const realUnit = unitsCorrespondence[unit];
|
|
364
|
-
switch (realUnit) {
|
|
365
|
-
case 'y':
|
|
366
|
-
return this.year <= d.year;
|
|
367
|
-
case 'm':
|
|
368
|
-
return (this.year <= d.year) || (this.year === d.year && this.month <= d.month);
|
|
369
|
-
case 'd':
|
|
370
|
-
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);
|
|
371
|
-
case 'h':
|
|
372
|
-
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);
|
|
373
|
-
case 'n':
|
|
374
|
-
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);
|
|
375
|
-
case 's':
|
|
376
|
-
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);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
return this.mtst < d.mtst;
|
|
381
|
-
}*/
|
|
382
349
|
calendar(format) {
|
|
383
350
|
let str = '';
|
|
384
351
|
if (format) {
|