Skip to content

Commit 26173e5

Browse files
committed
fix: Custom parser is not enabled
1 parent f315825 commit 26173e5

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

backend/routes/api.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ const configClass = require("../classes/config");
1111
const { checkForUpdates } = require("../version-control");
1212
const API = require("../classes/api-loader");
1313
const { sendUpdate } = require("../ws");
14-
const dayjs = require("dayjs");
1514
const { tables } = require("../global/backup_tables");
1615
const TaskScheduler = require("../classes/task-scheduler-singleton");
1716
const TaskManager = require("../classes/task-manager-singleton.js");
1817

18+
const dayjs = require("dayjs");
19+
const customParseFormat = require("dayjs/plugin/customParseFormat");
20+
dayjs.extend(customParseFormat);
21+
1922
const router = express.Router();
2023

2124
//consts

backend/routes/stats.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
const express = require("express");
33
const db = require("../db");
44
const dbHelper = require("../classes/db-helper");
5+
56
const dayjs = require("dayjs");
7+
const customParseFormat = require("dayjs/plugin/customParseFormat");
8+
dayjs.extend(customParseFormat);
69

710
const router = express.Router();
811

@@ -294,7 +297,7 @@ router.post("/getLibraryItemsPlayMethodStats", async (req, res) => {
294297
// Validate startDate and endDate using dayjs
295298
if (
296299
startDate !== undefined &&
297-
(!dayjs(startDate, dayjs.ISO_8601, true).isValid() || !dayjs(endDate, dayjs.ISO_8601, true).isValid())
300+
(!dayjs(startDate, "YYYY-MM-DDTHH:mm:ss.SSSZ", true).isValid() || !dayjs(endDate, "YYYY-MM-DDTHH:mm:ss.SSSZ", true).isValid())
298301
) {
299302
return res.status(400).send({ error: "Invalid date format" });
300303
}

0 commit comments

Comments
 (0)