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.
Files changed (2) hide show
  1. package/lib/data.js +7 -4
  2. 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
- if (rDate.test(text)) {
164
- const localDate = new Date(text);
165
- return new Date(localDate.getUTCFullYear(), localDate.getUTCMonth(), localDate.getUTCDate());
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 = /^\d{4}-\d{2}-\d{2}$/;
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
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "2.2.11",
4
+ "version": "2.2.12",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",