-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pediy wrong timezone issue (#873)
- Loading branch information
1 parent
c0c7817
commit 7881264
Showing
2 changed files
with
58 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const pediyUtils = { | ||
dateParser: (html, timeZone) => { | ||
let math; | ||
let date = new Date(); | ||
if (/(\d+)ειε/.exec(html)) { | ||
math = /(\d+)ειε/.exec(html); | ||
date.setMinutes(date.getMinutes() - math[1]); | ||
return date.toUTCString(); | ||
} else if (/(\d+)ε°ζΆε/.exec(html)) { | ||
math = /(\d+)ε°ζΆε/.exec(html); | ||
date.setHours(date.getHours() - math[1]); | ||
return date.toUTCString(); | ||
} else if (/(\d+)倩ε/.exec(html)) { | ||
math = /(\d+)倩ε/.exec(html); | ||
date.setDate(date.getDate() - math[1]); | ||
return date.toUTCString(); | ||
} else if (/(\d+)-(\d+)-(\d+) (\d+):(\d+)/.exec(html)) { | ||
math = /(\d+)-(\d+)-(\d+) (\d+):(\d+)/.exec(html); | ||
date = new Date(math[1], parseInt(math[2]) - 1, math[3], math[4], math[5]); | ||
const serverOffset = new Date().getTimezoneOffset() / 60; | ||
return new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString(); | ||
} | ||
return html; | ||
}, | ||
}; | ||
|
||
module.exports = pediyUtils; |