nodebb-plugin-equipment-calendar 8.9.3 → 8.9.4
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/library.js +12 -10
- package/package.json +1 -1
- package/plugin.json +1 -1
package/library.js
CHANGED
|
@@ -1328,25 +1328,26 @@ async function handleCreateReservation(req, res) {
|
|
|
1328
1328
|
const itemIds = normalizeItemIds(itemIdsRaw);
|
|
1329
1329
|
if (!itemIds.length) return res.status(400).send('itemIds required');
|
|
1330
1330
|
|
|
1331
|
-
// Dates
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1331
|
+
// Dates: accept YYYY-MM-DD or ISO-with-time; take first 10 chars
|
|
1332
|
+
let _startIso = String(req.body.start || req.body.startDate || req.body.startIso || req.body.startStr || '').trim().slice(0, 10);
|
|
1333
|
+
let _endIso = String(req.body.end || req.body.endDate || req.body.endIso || req.body.endStr || '').trim().slice(0, 10);
|
|
1334
|
+
|
|
1335
|
+
// Fallback: timestamps
|
|
1336
1336
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(_startIso)) {
|
|
1337
1337
|
const ms = Number(req.body.startMs || req.body.startTime || 0);
|
|
1338
|
-
if (ms) _startIso = new Date(ms).toISOString().slice(0,10);
|
|
1338
|
+
if (ms) _startIso = new Date(ms).toISOString().slice(0, 10);
|
|
1339
1339
|
}
|
|
1340
1340
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(_endIso)) {
|
|
1341
1341
|
const ms = Number(req.body.endMs || req.body.endTime || 0);
|
|
1342
|
-
if (ms) _endIso = new Date(ms).toISOString().slice(0,10);
|
|
1342
|
+
if (ms) _endIso = new Date(ms).toISOString().slice(0, 10);
|
|
1343
1343
|
}
|
|
1344
|
+
|
|
1344
1345
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(_startIso) || !/^\d{4}-\d{2}-\d{2}$/.test(_endIso)) {
|
|
1345
1346
|
return res.status(400).send('dates required');
|
|
1346
1347
|
}
|
|
1347
1348
|
|
|
1348
1349
|
const startMs = Date.parse(_startIso + 'T00:00:00Z');
|
|
1349
|
-
const endMs = Date.parse(addDaysIso(
|
|
1350
|
+
const endMs = Date.parse(addDaysIso(_endIso, 1) + 'T00:00:00Z'); // exclusive end
|
|
1350
1351
|
if (!startMs || !endMs || endMs <= startMs) {
|
|
1351
1352
|
return res.status(400).send('dates required');
|
|
1352
1353
|
}
|
|
@@ -1374,8 +1375,8 @@ async function handleCreateReservation(req, res) {
|
|
|
1374
1375
|
itemId,
|
|
1375
1376
|
startMs,
|
|
1376
1377
|
endMs,
|
|
1377
|
-
|
|
1378
|
-
|
|
1378
|
+
startIso: _startIso,
|
|
1379
|
+
endIso: _endIso,
|
|
1379
1380
|
days,
|
|
1380
1381
|
unitPrice,
|
|
1381
1382
|
total,
|
|
@@ -1395,6 +1396,7 @@ async function handleCreateReservation(req, res) {
|
|
|
1395
1396
|
}
|
|
1396
1397
|
|
|
1397
1398
|
|
|
1399
|
+
|
|
1398
1400
|
async function handleApproveReservation(req, res) {
|
|
1399
1401
|
try {
|
|
1400
1402
|
const settings = await getSettings();
|
package/package.json
CHANGED