mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 18:48:12 +08:00
test: utils/date
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// 格式化 类型这个的时间 , 几分钟前 | 几小时前 | 几天前 | 几月前 | 几年前 | 具体的格式不对的时间
|
||||
module.exports = (html, timeZone) => {
|
||||
const serverOffset = new Date().getTimezoneOffset() / 60;
|
||||
|
||||
module.exports = (html, timeZone = -serverOffset) => {
|
||||
let math;
|
||||
let date = new Date();
|
||||
if (/(\d+)分钟前/.exec(html)) {
|
||||
@@ -46,8 +48,7 @@ module.exports = (html, timeZone) => {
|
||||
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), math[1], math[2]);
|
||||
}
|
||||
|
||||
if (date && timeZone) {
|
||||
const serverOffset = new Date().getTimezoneOffset() / 60;
|
||||
if (date) {
|
||||
return new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString();
|
||||
}
|
||||
return html;
|
||||
|
||||
Reference in New Issue
Block a user