From 719cc1994b10bc96fcd17df6cf2046023d0cd9ba Mon Sep 17 00:00:00 2001 From: Jiamin <16831220+magazian@users.noreply.github.com> Date: Mon, 6 Jul 2026 02:03:12 +0800 Subject: [PATCH] fix: fix timezone for GMT+8 (#22270) * fix: fix timezone for GMT+8 * fix: update +8 to 8 --- lib/routes/sdmuseum/exhibitions.tsx | 3 ++- lib/routes/shanghaimuseum/news.ts | 3 ++- lib/routes/shanghaimuseum/offline-exhibit.tsx | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/routes/sdmuseum/exhibitions.tsx b/lib/routes/sdmuseum/exhibitions.tsx index c89178e63..85d5b76c3 100644 --- a/lib/routes/sdmuseum/exhibitions.tsx +++ b/lib/routes/sdmuseum/exhibitions.tsx @@ -5,6 +5,7 @@ import type { DataItem, Route } from '@/types'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; +import timezone from '@/utils/timezone'; import { namespace } from './namespace'; @@ -108,7 +109,7 @@ export const route: Route = { const $detail = load(detailResponse.data); const pubDateStr = $detail('meta[name="PubDate"]').attr('content') || ''; - const pubDate = parseDate(pubDateStr, 'YYYY-MM-DD HH:mm'); + const pubDate = timezone(parseDate(pubDateStr, 'YYYY-MM-DD HH:mm'), 8); const description = renderToString(
diff --git a/lib/routes/shanghaimuseum/news.ts b/lib/routes/shanghaimuseum/news.ts index 3318561c4..ade52da50 100644 --- a/lib/routes/shanghaimuseum/news.ts +++ b/lib/routes/shanghaimuseum/news.ts @@ -1,5 +1,6 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; +import timezone from '@/utils/timezone'; export const route = { path: '/information/news/:type?', @@ -67,7 +68,7 @@ export const route = { return { title: item.titleDecoded || item.title, - pubDate: parseDate(item.issueTime), + pubDate: timezone(parseDate(item.issueTime), 8), category: item.infoType?.entryItemName || item.bulletinInfoType?.entryItemName, link: itemLink, }; diff --git a/lib/routes/shanghaimuseum/offline-exhibit.tsx b/lib/routes/shanghaimuseum/offline-exhibit.tsx index 6e784466d..d4ed23112 100644 --- a/lib/routes/shanghaimuseum/offline-exhibit.tsx +++ b/lib/routes/shanghaimuseum/offline-exhibit.tsx @@ -3,6 +3,7 @@ import { renderToString } from 'hono/jsx/dom/server'; import type { Route } from '@/types'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; +import timezone from '@/utils/timezone'; import { namespace } from './namespace'; @@ -32,7 +33,7 @@ export const route: Route = { }, ], handler: async (ctx) => { - const type = ctx.req.param('type')?.toUpperCase(); + const type = ctx.req.param('type'); const baseUrl = 'https://www.shanghaimuseum.net'; const apiUrl = `${baseUrl}/mu/frontend/pg/display/search-exhibit`; @@ -73,7 +74,7 @@ export const route: Route = { const itemLink = `${baseUrl}/mu/frontend/pg/article/id/${item.code}`; const imgUrl = item.picPath ? `${baseUrl}/${item.picPath}` : ''; const location = item.exhibitPlace || '上海博物馆'; - const pubDate = parseDate(item.issueTime); + const pubDate = timezone(parseDate(item.issueTime), 8); const fullDuration = item.exhibitDateRange || ''; const [startDate, endDate] = fullDuration.includes(' - ') ? fullDuration.split(' - ').map((s) => s.trim()) : [fullDuration, ''];