mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix weibo user pubDate
This commit is contained in:
+30
-1
@@ -40,6 +40,35 @@ function format (status) {
|
||||
return temp;
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
function getTime (html) {
|
||||
console.log(html);
|
||||
let math;
|
||||
let date = new Date();
|
||||
if (/(\d+)分钟前/.exec(html)) {
|
||||
math = /(\d+)分钟前/.exec(html);
|
||||
date.setMinutes(date.getMinutes() - math[1]);
|
||||
return date.toUTCString();
|
||||
} else if (/(\d+)小时前/.exec(html)) {
|
||||
math = /(\d+)小时前/.exec(html);
|
||||
date.setHours(date.getHours() - math[1]);
|
||||
return date.toUTCString();
|
||||
} else if (/今天 (\d+):(\d+)/.exec(html)) {
|
||||
math = /今天 (\d+):(\d+)/.exec(html);
|
||||
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), math[1], math[2]);
|
||||
return date.toUTCString();
|
||||
} else if (/昨天 (\d+):(\d+)/.exec(html)) {
|
||||
math = /昨天 (\d+):(\d+)/.exec(html);
|
||||
date = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1, math[1], math[2]);
|
||||
return date.toUTCString();
|
||||
} else if (/(\d+)月(\d+)日 (\d+):(\d+)/.exec(html)) {
|
||||
math = /(\d+)月(\d+)日 (\d+):(\d+)/.exec(html);
|
||||
date = new Date(date.getFullYear(), math[1] - 1, parseInt(math[2]), math[3], math[4]);
|
||||
return date.toUTCString();
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
|
||||
@@ -73,7 +102,7 @@ module.exports = async (ctx) => {
|
||||
return {
|
||||
title: title.length > 24 ? title.slice(0, 24) + '...' : title,
|
||||
description: format(item.mblog),
|
||||
pubDate: new Date(item.mblog.created_at.length === 5 ? `${new Date().getFullYear()}-${item.mblog.created_at}` : item.mblog.created_at).toUTCString(),
|
||||
pubDate: getTime(item.mblog.created_at),
|
||||
link: `https://weibo.com/${uid}/${item.mblog.bid}`
|
||||
};
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user