@bbn/bbn 1.0.447 → 1.0.448
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 +2 -2
- package/dist/date.js +49 -18
- package/dist/fn/datetime/dateSQL.js +2 -3
- package/package.json +1 -1
package/dist/date.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ declare class bbnDateTool {
|
|
|
16
16
|
get MM(): string;
|
|
17
17
|
get DD(): string;
|
|
18
18
|
get HH(): string;
|
|
19
|
-
get
|
|
20
|
-
get
|
|
19
|
+
get II(): string;
|
|
20
|
+
get SS(): string;
|
|
21
21
|
add(value: number, unit?: string): bbnDateTool | null;
|
|
22
22
|
sub(value: number, unit: string | null): bbnDateTool;
|
|
23
23
|
dateFromFormat(value: string, unit: string | null): Date;
|
package/dist/date.js
CHANGED
|
@@ -99,7 +99,7 @@ const unitsMap = {
|
|
|
99
99
|
'm': 'Month',
|
|
100
100
|
'd': 'Date',
|
|
101
101
|
'h': 'Hours',
|
|
102
|
-
'
|
|
102
|
+
'i': 'Minutes',
|
|
103
103
|
's': 'Seconds'
|
|
104
104
|
};
|
|
105
105
|
const formatsMap = {
|
|
@@ -107,41 +107,72 @@ const formatsMap = {
|
|
|
107
107
|
'm': 'MM',
|
|
108
108
|
'd': 'DD',
|
|
109
109
|
'h': 'HH',
|
|
110
|
-
'
|
|
111
|
-
's': '
|
|
110
|
+
'i': 'II',
|
|
111
|
+
's': 'SS'
|
|
112
112
|
};
|
|
113
113
|
const unitsCorrespondence = {
|
|
114
|
+
'years': 'y',
|
|
115
|
+
'year': 'y',
|
|
116
|
+
'YEARS': 'y',
|
|
117
|
+
'YEAR': 'y',
|
|
118
|
+
'Years': 'y',
|
|
119
|
+
'Year': 'y',
|
|
114
120
|
'YYYY': 'y',
|
|
115
121
|
'YY': 'y',
|
|
116
122
|
'yyyy': 'y',
|
|
117
123
|
'yy': 'y',
|
|
118
|
-
'year': 'y',
|
|
119
124
|
'Y': 'y',
|
|
120
125
|
'y': 'y',
|
|
126
|
+
'months': 'm',
|
|
127
|
+
'month': 'm',
|
|
128
|
+
'Months': 'm',
|
|
129
|
+
'Month': 'm',
|
|
130
|
+
'MONTHS': 'm',
|
|
131
|
+
'MONTH': 'm',
|
|
121
132
|
'MM': 'm',
|
|
122
133
|
'M': 'm',
|
|
123
|
-
'month': 'm',
|
|
124
|
-
'mm': 'm',
|
|
125
134
|
'm': 'm',
|
|
126
|
-
'
|
|
135
|
+
'days': 'd',
|
|
127
136
|
'day': 'd',
|
|
137
|
+
'Days': 'd',
|
|
138
|
+
'Day': 'd',
|
|
139
|
+
'DAYS': 'd',
|
|
140
|
+
'DAY': 'd',
|
|
141
|
+
'DD': 'd',
|
|
128
142
|
'D': 'd',
|
|
129
143
|
'dd': 'd',
|
|
130
144
|
'd': 'd',
|
|
145
|
+
'hours': 'h',
|
|
146
|
+
'hour': 'h',
|
|
147
|
+
'Hours': 'h',
|
|
148
|
+
'Hour': 'h',
|
|
149
|
+
'HOURS': 'h',
|
|
150
|
+
'HOUR': 'h',
|
|
131
151
|
'HH': 'h',
|
|
132
152
|
'hr': 'h',
|
|
133
|
-
'hour': 'h',
|
|
134
153
|
'H': 'h',
|
|
135
154
|
'hh': 'h',
|
|
136
155
|
'h': 'h',
|
|
137
|
-
'
|
|
138
|
-
'
|
|
139
|
-
'
|
|
140
|
-
'
|
|
141
|
-
'
|
|
142
|
-
'
|
|
156
|
+
'minutes': 'i',
|
|
157
|
+
'minute': 'i',
|
|
158
|
+
'Minutes': 'i',
|
|
159
|
+
'Minute': 'i',
|
|
160
|
+
'MINUTES': 'i',
|
|
161
|
+
'MINUTE': 'i',
|
|
162
|
+
'II': 'i',
|
|
163
|
+
'ii': 'i',
|
|
164
|
+
'mn': 'i',
|
|
165
|
+
'mm': 'i',
|
|
166
|
+
'min': 'i',
|
|
167
|
+
'n': 'i',
|
|
143
168
|
'SS': 's',
|
|
144
169
|
'ss': 's',
|
|
170
|
+
'seconds': 's',
|
|
171
|
+
'second': 's',
|
|
172
|
+
'Seconds': 's',
|
|
173
|
+
'Second': 's',
|
|
174
|
+
'SECONDS': 's',
|
|
175
|
+
'SECOND': 's',
|
|
145
176
|
'sec': 's',
|
|
146
177
|
's': 's',
|
|
147
178
|
'S': 's',
|
|
@@ -242,10 +273,10 @@ class bbnDateTool {
|
|
|
242
273
|
get HH() {
|
|
243
274
|
return this.hours < 10 ? '0' + this.hours.toString() : this.hours.toString();
|
|
244
275
|
}
|
|
245
|
-
get
|
|
276
|
+
get II() {
|
|
246
277
|
return this.minutes < 10 ? '0' + this.minutes.toString() : this.minutes.toString();
|
|
247
278
|
}
|
|
248
|
-
get
|
|
279
|
+
get SS() {
|
|
249
280
|
return this.seconds < 10 ? '0' + this.seconds.toString() : this.seconds.toString();
|
|
250
281
|
}
|
|
251
282
|
add(value, unit = 'd') {
|
|
@@ -267,7 +298,7 @@ class bbnDateTool {
|
|
|
267
298
|
const d = new Date();
|
|
268
299
|
return d;
|
|
269
300
|
}
|
|
270
|
-
format(format = 'y-m-d h:
|
|
301
|
+
format(format = 'y-m-d h:i:s') {
|
|
271
302
|
let str = '';
|
|
272
303
|
if (format) {
|
|
273
304
|
const reg = new RegExp('(' + Object.keys(unitsCorrespondence).join('|') + ')', 'g');
|
|
@@ -312,7 +343,7 @@ class bbnDateTool {
|
|
|
312
343
|
}
|
|
313
344
|
return 0;
|
|
314
345
|
}
|
|
315
|
-
const order = ['y', 'm', 'd', 'h', '
|
|
346
|
+
const order = ['y', 'm', 'd', 'h', 'i', 's'];
|
|
316
347
|
// Compare step by step until the requested precision
|
|
317
348
|
for (const u of order) {
|
|
318
349
|
const key = unitsMap[u].toLowerCase();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import date from '
|
|
2
|
-
import dayjs from 'dayjs';
|
|
1
|
+
import date from '../../date.js';
|
|
3
2
|
/**
|
|
4
3
|
* Returns a date with SQL format.
|
|
5
4
|
*
|
|
@@ -21,7 +20,7 @@ import dayjs from 'dayjs';
|
|
|
21
20
|
export default function dateSQL(v, dayOnly) {
|
|
22
21
|
let value = date(v);
|
|
23
22
|
if (value) {
|
|
24
|
-
return
|
|
23
|
+
return value.format('YYYY-MM-DD' + (dayOnly ? '' : ' HH:mm:ss'));
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
;
|