date time

This commit is contained in:
2026-05-29 14:15:06 +07:00
parent 991d6f5257
commit 9cedf085a3
6 changed files with 82 additions and 9 deletions

View File

@@ -293,6 +293,16 @@ function getCurrentPath(req) {
return `${url.pathname}${url.search}` || '/';
}
function toDateInputValue(value = new Date()) {
const date = value instanceof Date ? value : new Date(value);
const safeDate = Number.isNaN(date.getTime()) ? new Date() : date;
const year = safeDate.getFullYear();
const month = String(safeDate.getMonth() + 1).padStart(2, '0');
const day = String(safeDate.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
function viewModel(req, active, title, pageData, extra = {}) {
const currentUser = pageData.currentUser || req.currentUser || {
name: 'Guest',
@@ -314,6 +324,7 @@ function viewModel(req, active, title, pageData, extra = {}) {
notice: getNotice(req),
currentPath: getCurrentPath(req),
databaseLabel: getSqlServerDisplayLabel(),
todayDate: toDateInputValue(),
helpers: helpers(),
...extra
};