Download lib/utils/timezone.ts from ASEM12345/rsshub: direct link, hf CLI and curl.
- Browser
- Download file 416 Bytes
-
https://huggingface.co/spaces/ASEM12345/rsshub/resolve/main/lib/utils/timezone.ts
- Command line
-
hf download hf://spaces/ASEM12345/rsshub/lib/utils/timezone.ts
-
curl -L -o timezone.ts https://huggingface.co/spaces/ASEM12345/rsshub/resolve/main/lib/utils/timezone.ts
416 Bytes
| 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)); | |
| } | |