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

@@ -152,7 +152,7 @@ GitHub 官方也提供了一些 RSS:
### 打卡 ### 打卡
<Route author="NathanDai" example="/leetcode/submission/us/nathandai" path="/leetcode/submission/us/:user" :paramsDesc="['现在只支持国际版的leetcode', '用户名 user, 可在LeetCode用户主页的 URL 中找到']"/> <Route author="NathanDai" example="/leetcode/submission/us/nathandai" path="/leetcode/submission/:country/:user" :paramsDesc="['国家 country, 中国(cn)和美国(us)', '用户名 user, 可在LeetCode用户主页的 URL 中找到']"/>
## LinkedKeeper ## LinkedKeeper

View File

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

View File

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

View File

@@ -28,25 +28,25 @@ const ProcessFeed = async (list) => {
const n5 = pubDate.search(/hour/); const n5 = pubDate.search(/hour/);
const n6 = pubDate.search(/minute/); const n6 = pubDate.search(/minute/);
if (n1 !== -1) { if (n1 !== -1) {
n = n + parseInt(pubDate[n1 - 2]) * 365; n = n + parseInt(pubDate.substring(n1 - 3, n1 - 1)) * 365;
} }
if (n2 !== -1) { if (n2 !== -1) {
n = n + parseInt(pubDate[n2 - 2]) * 30; n = n + parseInt(pubDate.substring(n2 - 3, n3 - 1)) * 30;
} }
if (n3 !== -1) { if (n3 !== -1) {
n = n + parseInt(pubDate[n3 - 2]) * 7; n = n + parseInt(pubDate.substring(n3 - 3, n3 - 1)) * 7;
} }
if (n4 !== -1) { if (n4 !== -1) {
n = n + parseInt(pubDate[n4 - 2]) * 1; n = n + parseInt(pubDate.substring(n4 - 3, n4 - 1)) * 1;
} }
if (n5 !== -1) { if (n5 !== -1) {
h = h + parseInt(pubDate[n5 - 2]) * 3600; h = h + parseInt(pubDate.substring(n5 - 3, n5 - 1)) * 3600;
} }
if (n6 !== -1) { 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 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 = { const single = {
title: $title.text(), title: $title.text(),