Skip to content

Commit

Permalink
fix(route): migrate weibo routes to new timezone (DIYgod#6795) (DIY…
Browse files Browse the repository at this point in the history
  • Loading branch information
queensferryme authored May 12, 2021
1 parent c06864c commit 6bed454
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions lib/routes/meipai/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const got = require('@/utils/got');
const cheerio = require('cheerio');
const util = require('./utils');

// const date = require('@/utils/date');

module.exports = async (ctx) => {
const uid = ctx.params.uid;

Expand Down
8 changes: 4 additions & 4 deletions lib/routes/weibo/keyword.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const querystring = require('querystring');
const got = require('@/utils/got');
const weiboUtils = require('./utils');
const date = require('@/utils/date');
const timezone = require('@/utils/timezone');
const { fallback, queryToBoolean } = require('@/utils/readable-social');

module.exports = async (ctx) => {
Expand All @@ -25,9 +25,9 @@ module.exports = async (ctx) => {
link: `http://s.weibo.com/weibo/${encodeURIComponent(keyword)}&b=1&nodup=1`,
description: `又有人在微博提到${keyword}了`,
item: data.map((item) => {
item.mblog.created_at = date(item.mblog.created_at, 8);
item.mblog.created_at = timezone(item.mblog.created_at, +8);
if (item.mblog.retweeted_status && item.mblog.retweeted_status.created_at) {
item.mblog.retweeted_status.created_at = date(item.mblog.retweeted_status.created_at, 8);
item.mblog.retweeted_status.created_at = timezone(item.mblog.retweeted_status.created_at, +8);
}
const formatExtended = weiboUtils.formatExtended(ctx, item.mblog, {
showAuthorInTitle: fallback(undefined, queryToBoolean(routeParams.showAuthorInTitle), true),
Expand All @@ -38,7 +38,7 @@ module.exports = async (ctx) => {
return {
title: title,
description: description,
pubDate: date(item.mblog.created_at, 8),
pubDate: item.mblog.created_at,
author: item.mblog.user.screen_name,
link: `https://weibo.com/${item.mblog.user.id}/${item.mblog.bid}`,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/weibo/user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const querystring = require('querystring');
const got = require('@/utils/got');
const weiboUtils = require('./utils');
const date = require('@/utils/date');
const timezone = require('@/utils/timezone');
const { fallback, queryToBoolean } = require('@/utils/readable-social');

module.exports = async (ctx) => {
Expand Down Expand Up @@ -78,7 +78,7 @@ module.exports = async (ctx) => {
let description = formatExtended.description;
const formattedTitle = formatExtended.title;
const title = formattedTitle;
const pubDate = isDataOK ? new Date(data.created_at).toUTCString() : date(item.mblog.created_at, 8);
const pubDate = isDataOK ? new Date(data.created_at) : timezone(item.mblog.created_at, +8);

// 视频的处理
if (displayVideo === '1') {
Expand Down

0 comments on commit 6bed454

Please sign in to comment.