UTC dates for date param so modlog doesnt get broken by timezones

merge-requests/208/head
fatchan 4 years ago
parent d38cd55b1d
commit 29e78c2e2b
  1. 6
      helpers/paramconverter.js
  2. 8
      models/pages/modlog.js

@ -104,10 +104,10 @@ module.exports = (req, res, next) => {
}
//moglog date
if (req.params.date) {
const dateString = req.params.date.replace(/-/g, '/');
const date = new Date(dateString);
const [ month, day, year ] = req.params.date.split('-');
const date = new Date(Date.UTC(year, month, day, 0, 0, 0, 0));
if (date !== 'Invalid Date') {
res.locals.date = date;
res.locals.date = { month, day, year, date };
}
}

@ -9,10 +9,10 @@ module.exports = async (req, res, next) => {
return next();
}
const startDate = new Date(res.locals.date);
const endDate = new Date(startDate.valueOf());
startDate.setHours(0,0,0,0);
endDate.setHours(23,59,59,999);
const startDate = res.locals.date.date;
const { year, month, day } = res.locals.date;
const endDate = new Date(Date.UTC(year, month, day, 23, 59, 59, 999));
let html;
try {
const logs = await Modlogs.findBetweenDate(res.locals.board, startDate, endDate);

Loading…
Cancel
Save