diff --git a/package.json b/package.json index 9872834..fcff831 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@prisma/client": "4.13.0", "bootstrap": "5.2.3", "cookie-parser": "1.4.6", + "dayjs": "1.11.7", "debug": "4.3.4", "express": "4.18.2", "express-session": "1.17.3", diff --git a/routes/index.js b/routes/index.js index 0a04dba..94debb0 100644 --- a/routes/index.js +++ b/routes/index.js @@ -4,6 +4,13 @@ const router = express.Router(); const { PrismaClient } = require('@prisma/client'); const prisma = new PrismaClient({ log: [ 'query' ] }); +const dayjs = require('dayjs'); +const utc = require('dayjs/plugin/utc'); +const timezone = require('dayjs/plugin/timezone'); +dayjs.extend(utc); +dayjs.extend(timezone); +dayjs.tz.setDefault('Asia/Tokyo'); + /* GET home page. */ router.get('/', async (req, res, next) => { const title = '予定調整くん'; @@ -12,6 +19,9 @@ router.get('/', async (req, res, next) => { where: { createdBy: parseInt(req.user.id) }, orderBy: { updatedAt: 'desc' } }); + schedules.forEach((schedule) => { + schedule.formattedUpdatedAt = dayjs(schedule.updatedAt).tz().format('YYYY/MM/DD HH:mm'); + }); res.render('index', { title: title, user: req.user, diff --git a/views/index.pug b/views/index.pug index cd22862..d18f241 100644 --- a/views/index.pug +++ b/views/index.pug @@ -19,4 +19,4 @@ block content tr td a(href=`/schedules/${schedule.scheduleId}`) #{schedule.scheduleName} - td #{schedule.updatedAt} + td #{schedule.formattedUpdatedAt}