mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 02:28:23 +08:00
15 lines
421 B
JavaScript
15 lines
421 B
JavaScript
const assert = require('assert').strict;
|
|
|
|
const millisInAnHour = 60 * 60 * 1000;
|
|
const serverTimezone = -new Date().getTimezoneOffset() / 60;
|
|
|
|
module.exports = (date, timezone = serverTimezone) => {
|
|
if (typeof date === 'string' || date instanceof String) {
|
|
date = new Date(date);
|
|
}
|
|
|
|
assert(date instanceof Date);
|
|
|
|
return new Date(date.getTime() - millisInAnHour * (timezone - serverTimezone));
|
|
};
|