date time
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user