Skip to content

Commit

Permalink
修复微博-方案2 日期错误 (DIYgod#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryQW authored and DIYgod committed Oct 16, 2018
1 parent 99548d8 commit aec2341
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ module.exports = (html, timeZone) => {
} 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+)/.exec(html)) {
math = /(\d+):(\d+)/.exec(html);
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), math[1], math[2]);
} 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]);
Expand All @@ -41,7 +38,11 @@ module.exports = (html, timeZone) => {
} else if (/(\d+)-(\d+)/.exec(html)) {
math = /(\d+)-(\d+)/.exec(html);
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]);
} else if (/(\d+):(\d+)/.exec(html)) {
math = /(\d+):(\d+)/.exec(html);
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), math[1], math[2]);
}

if (date && timeZone) {
const serverOffset = new Date().getTimezoneOffset() / 60;
return new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString();
Expand Down

0 comments on commit aec2341

Please sign in to comment.