mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: OSChina 新闻抓取的时候解析时间字符串 (#2062)
This commit is contained in:
@@ -26,6 +26,9 @@ module.exports = (html, timeZone = -serverOffset) => {
|
||||
} 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]);
|
||||
} else if (/前天\s*(\d+):(\d+)/.exec(html)) {
|
||||
math = /前天\s*(\d+):(\d+)/.exec(html);
|
||||
date = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 2, math[1], math[2]);
|
||||
} else if (/(\d+)年(\d+)月(\d+)日(\d+)时/.exec(html)) {
|
||||
math = /(\d+)年(\d+)月(\d+)日(\d+)时/.exec(html);
|
||||
date = new Date(parseInt(math[1]), parseInt(math[2]) - 1, parseInt(math[3]), parseInt(math[4]));
|
||||
@@ -38,6 +41,12 @@ module.exports = (html, timeZone = -serverOffset) => {
|
||||
} else if (/(\d+)-(\d+) (\d+):(\d+)/.exec(html)) {
|
||||
math = /(\d+)-(\d+) (\d+):(\d+)/.exec(html);
|
||||
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2], math[3], math[4]);
|
||||
} else if (/(\d+)\/(\d+)\/(\d+)\s*(\d+):(\d+)/.exec(html)) {
|
||||
math = /(\d+)\/(\d+)\/(\d+)\s*(\d+):(\d+)/.exec(html);
|
||||
date = new Date(math[1], parseInt(math[2]) - 1, math[3], math[4], math[5]);
|
||||
} else if (/(\d+)\/(\d+)\s*(\d+):(\d+)/.exec(html)) {
|
||||
math = /(\d+)\/(\d+)\s*(\d+):(\d+)/.exec(html);
|
||||
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2], math[3], math[4]);
|
||||
} else if (/(\d+)月(\d+)日 (\d+):(\d+)/.exec(html)) {
|
||||
math = /(\d+)月(\d+)日 (\d+):(\d+)/.exec(html);
|
||||
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2], math[3], math[4]);
|
||||
|
||||
Reference in New Issue
Block a user