bare-script 2.2.11 → 2.2.12
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/lib/data.js +7 -4
- package/package.json +1 -1
package/lib/data.js
CHANGED
|
@@ -160,16 +160,19 @@ function parseNumber(text) {
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
export function parseDatetime(text) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
const mDate = text.match(rDate);
|
|
164
|
+
if (mDate !== null) {
|
|
165
|
+
const year = Number.parseInt(mDate.groups.year, 10);
|
|
166
|
+
const month = Number.parseInt(mDate.groups.month, 10);
|
|
167
|
+
const day = Number.parseInt(mDate.groups.day, 10);
|
|
168
|
+
return new Date(year, month - 1, day);
|
|
166
169
|
} else if (rDatetime.test(text)) {
|
|
167
170
|
return new Date(text);
|
|
168
171
|
}
|
|
169
172
|
return null;
|
|
170
173
|
}
|
|
171
174
|
|
|
172
|
-
const rDate =
|
|
175
|
+
const rDate = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/;
|
|
173
176
|
const rDatetime = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
174
177
|
|
|
175
178
|
|