fix: leetcode pubDate 的不正确 fix leetcode 打卡文档 (#2397)

This commit is contained in:
Nathan
2019-06-13 15:25:08 +08:00
committed by DIYgod
parent 19e0ea28af
commit 96b1c47987
4 changed files with 11 additions and 9 deletions

View File

@@ -84,8 +84,9 @@ module.exports = async (ctx) => {
A_20: 'compile-error',
A_30: 'timeout',
};
const state = ' 提交记录';
ctx.state.data = {
title: userSlug + ' 提交记录',
title: userSlug + state,
link: `https://leetcode-cn.com/u/${user}`,
description: description,
item: recentSubmissions.map((item) => ({

View File

@@ -47,6 +47,7 @@ module.exports = async (ctx) => {
const result = await util.ProcessFeed(list);
ctx.state.data = {
title: username + state,
link: `https://leetcode.com/${user}`,
description: description,
item: result,
};

View File

@@ -28,25 +28,25 @@ const ProcessFeed = async (list) => {
const n5 = pubDate.search(/hour/);
const n6 = pubDate.search(/minute/);
if (n1 !== -1) {
n = n + parseInt(pubDate[n1 - 2]) * 365;
n = n + parseInt(pubDate.substring(n1 - 3, n1 - 1)) * 365;
}
if (n2 !== -1) {
n = n + parseInt(pubDate[n2 - 2]) * 30;
n = n + parseInt(pubDate.substring(n2 - 3, n3 - 1)) * 30;
}
if (n3 !== -1) {
n = n + parseInt(pubDate[n3 - 2]) * 7;
n = n + parseInt(pubDate.substring(n3 - 3, n3 - 1)) * 7;
}
if (n4 !== -1) {
n = n + parseInt(pubDate[n4 - 2]) * 1;
n = n + parseInt(pubDate.substring(n4 - 3, n4 - 1)) * 1;
}
if (n5 !== -1) {
h = h + parseInt(pubDate[n5 - 2]) * 3600;
h = h + parseInt(pubDate.substring(n5 - 3, n5 - 1)) * 3600;
}
if (n6 !== -1) {
h = h + parseInt(pubDate[n6 - 2]) * 60;
h = h + parseInt(pubDate.substring(n6 - 3, n6 - 1)) * 60;
}
const now = new Date();
const Datenow = new Date(now.getTime() - n * 24 * 3600 * 1000 - h * 1000).toISOString();
const Datenow = new Date(now.getTime() - n * 24 * 3600 * 1000 - h * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
// 列表上提取到的信息
const single = {
title: $title.text(),