mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
03969f3867
* fix: unicorn/no-empty-file * fix: unicorn/prefer-node-protocol * fix: unicorn/prefer-number-properties * fix: unicorn/consistent-destructuring * fix: unicorn/no-array-callback-reference * fix: unicorn/new-for-builtins * fix: set checkNaN to false in unicorn/prefer-number-properties * fix: unicorn/prefer-string-slice * fix: update eslint ignore
15 lines
416 B
TypeScript
15 lines
416 B
TypeScript
import { strict as assert } from 'node:assert';
|
|
|
|
const millisInAnHour = 60 * 60 * 1000;
|
|
const serverTimezone = -new Date().getTimezoneOffset() / 60;
|
|
|
|
export default function timezone(date, timezone = serverTimezone) {
|
|
if (typeof date === 'string') {
|
|
date = new Date(date);
|
|
}
|
|
|
|
assert.ok(date instanceof Date);
|
|
|
|
return new Date(date.getTime() - millisInAnHour * (timezone - serverTimezone));
|
|
}
|