From c06864c427af4bc54ee891e7ef4effc587299bf4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A5=9E=E6=A5=BD=E5=9D=82=E3=81=BF=E3=81=9A=E3=81=8D?=
<45122329+CokeMine@users.noreply.github.com>
Date: Wed, 12 May 2021 12:36:27 +0800
Subject: [PATCH] fix(route): migrate smzdm to new time parser, re #6795
(#7515)
---
lib/routes/smzdm/article.js | 5 +++--
lib/routes/smzdm/baoliao.js | 3 +--
lib/routes/smzdm/haowen.js | 5 +++--
lib/routes/smzdm/haowen_fenlei.js | 6 +++---
lib/routes/smzdm/keyword.js | 5 +++--
lib/routes/smzdm/ranking.js | 4 ++--
6 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/lib/routes/smzdm/article.js b/lib/routes/smzdm/article.js
index c51b9f1767c8b7..4cbde98a3b08c8 100644
--- a/lib/routes/smzdm/article.js
+++ b/lib/routes/smzdm/article.js
@@ -1,6 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const date = require('@/utils/date');
+const parseDate = require('@/utils/parse-date');
+const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
const link = `https://zhiyou.smzdm.com/member/${ctx.params.uid}/article/`;
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
- pubDate: date(pubdate),
+ pubDate: timezone(parseDate(pubdate, 'MM-DD H:mm'), +8),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
diff --git a/lib/routes/smzdm/baoliao.js b/lib/routes/smzdm/baoliao.js
index 142181df263066..c288e99e3519de 100644
--- a/lib/routes/smzdm/baoliao.js
+++ b/lib/routes/smzdm/baoliao.js
@@ -1,6 +1,5 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const date = require('@/utils/date');
module.exports = async (ctx) => {
const link = `https://zhiyou.smzdm.com/member/${ctx.params.uid}/baoliao/`;
@@ -41,7 +40,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
- pubDate: date(pubdate),
+ pubDate: new Date(pubdate),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
diff --git a/lib/routes/smzdm/haowen.js b/lib/routes/smzdm/haowen.js
index 4557fa30cb6557..dd842ad9a9b939 100644
--- a/lib/routes/smzdm/haowen.js
+++ b/lib/routes/smzdm/haowen.js
@@ -1,6 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const date = require('@/utils/date');
+const parseDate = require('@/utils/parse-date');
+const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
const day = ctx.params.day || 'all';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
- pubDate: date(pubdate),
+ pubDate: timezone(parseDate(pubdate, 'H:mm'), +8),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
diff --git a/lib/routes/smzdm/haowen_fenlei.js b/lib/routes/smzdm/haowen_fenlei.js
index 517a3b1a0b82d5..ebcb880803cc06 100644
--- a/lib/routes/smzdm/haowen_fenlei.js
+++ b/lib/routes/smzdm/haowen_fenlei.js
@@ -1,7 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const date = require('@/utils/date');
-
+const timezone = require('@/utils/timezone');
+const parseDate = require('@/utils/parse-date');
module.exports = async (ctx) => {
const name = ctx.params.name;
const sort = ctx.params.sort || '0';
@@ -48,7 +48,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
- pubDate: date(pubdate),
+ pubDate: timezone(parseDate(pubdate, 'H:mm'), +8),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
diff --git a/lib/routes/smzdm/keyword.js b/lib/routes/smzdm/keyword.js
index 11d6345643fcef..b72cfc8eb1d8fc 100644
--- a/lib/routes/smzdm/keyword.js
+++ b/lib/routes/smzdm/keyword.js
@@ -1,6 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const formatPubDate = require('@/utils/date.js');
+const parseDate = require('@/utils/parse-date');
+const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
const keyword = ctx.params.keyword;
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
return {
title: `${item.find('.feed-block-title a').eq(0).text().trim()} - ${item.find('.feed-block-title a').eq(1).text().trim()}`,
description: `${item.find('.feed-block-descripe').contents().eq(2).text().trim()}
${item.find('.feed-block-extras span').text().trim()}
`,
- pubDate: formatPubDate(item.find('.feed-block-extras').contents().eq(0).text().trim(), 8),
+ pubDate: timezone(parseDate(item.find('.feed-block-extras').contents().eq(0).text().trim(), 'H:mm'), +8),
link: `${item.find('.feed-block-title a').attr('href')}`,
};
})
diff --git a/lib/routes/smzdm/ranking.js b/lib/routes/smzdm/ranking.js
index e66f54c7772af4..b7411793f57230 100644
--- a/lib/routes/smzdm/ranking.js
+++ b/lib/routes/smzdm/ranking.js
@@ -1,5 +1,5 @@
const got = require('@/utils/got');
-const date = require('@/utils/date');
+const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
const { rank_type, rank_id, hour } = ctx.params;
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
item: list.map((item) => ({
title: `${item.article_title} - ${item.article_price}`,
description: `${item.article_title} - ${item.article_price}
`,
- pubDate: date(item.article_pubdate, 8),
+ pubDate: timezone(item.article_pubdate, +8),
link: item.article_url,
})),
};