mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-15 07:18:19 +01:00
pls work
This commit is contained in:
parent
0a35ab0cf0
commit
3ddc1e072d
1 changed files with 5 additions and 5 deletions
|
@ -168,21 +168,21 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/calendar', (req, res) => {
|
app.get('/calendar', (req, res) => {
|
||||||
|
// Get the date from query or default to today
|
||||||
const queryDate = req.query.date ? new Date(req.query.date) : new Date();
|
const queryDate = req.query.date ? new Date(req.query.date) : new Date();
|
||||||
|
|
||||||
|
// Extract the year and month from the date
|
||||||
const year = queryDate.getFullYear();
|
const year = queryDate.getFullYear();
|
||||||
const month = queryDate.getMonth(); // 0 (January) to 11 (December)
|
const month = queryDate.getMonth(); // 0 (January) to 11 (December)
|
||||||
|
|
||||||
const monthOffset = parseInt(req.query.month) || 0; // Get month offset from query
|
const monthOffset = parseInt(req.query.month) || 0;
|
||||||
const newDate = new Date(year, month + monthOffset, 1); // Adjust the month
|
const newDate = new Date(year, month + monthOffset, 1);
|
||||||
const newYear = newDate.getFullYear();
|
const newYear = newDate.getFullYear();
|
||||||
const newMonth = newDate.getMonth();
|
const newMonth = newDate.getMonth();
|
||||||
|
|
||||||
const firstDay = new Date(newYear, newMonth, 1);
|
const firstDay = new Date(newYear, newMonth, 1);
|
||||||
const firstDayWeekday = firstDay.getDay(); // Day of the week (0-6)
|
const firstDayWeekday = firstDay.getDay(); // Day of the week (0-6)
|
||||||
|
|
||||||
const totalDays = new Date(newYear, newMonth + 1, 0).getDate();
|
|
||||||
|
|
||||||
const days = Array.from({ length: 42 }, (_, i) => {
|
const days = Array.from({ length: 42 }, (_, i) => {
|
||||||
const day = new Date(newYear, newMonth, i - firstDayWeekday + 1);
|
const day = new Date(newYear, newMonth, i - firstDayWeekday + 1);
|
||||||
return (day.getMonth() === newMonth) ? day : null;
|
return (day.getMonth() === newMonth) ? day : null;
|
||||||
|
@ -192,7 +192,7 @@ app.get('/calendar', (req, res) => {
|
||||||
const persianYear = gregorianToPersian(newDate);
|
const persianYear = gregorianToPersian(newDate);
|
||||||
|
|
||||||
renderTemplate(res, req, "calendar.ejs", {
|
renderTemplate(res, req, "calendar.ejs", {
|
||||||
year: newYear,
|
year: newYear,
|
||||||
islamicYear,
|
islamicYear,
|
||||||
persianYear,
|
persianYear,
|
||||||
currentDate: newDate,
|
currentDate: newDate,
|
||||||
|
|
Loading…
Reference in a new issue