Setting Environment variable TZ does not affect Date.getTimezoneOffset()
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 681
- PR merge metrics
- No merged PRs in 30d
Description
## Datetime timezoneoffset has not been implemented?
Run this script with deno (can use `process.env.TZ` or `Deno.env.set` method):
```ts
import process from 'node:process';
const now = new Date();
console.log(now.getTimezoneOffset(), 'default');
['America/Costa_Rica', 'EST', 'America/St_Johns', 'UTC', 'America/Vancouver', 'Australia/Adelaide'].forEach(
(tz) => {
process.env.TZ = tz;
console.log(now.getTimezoneOffset(), tz);
}
);
```
Actual output:
```txt
360 default
360 America/Costa_Rica
360 EST
360 America/St_Johns
360 UTC
360 America/Vancouver
360 Australia/Adelaide
```
Then run this with node:
```js
const process = require('node:process');
const now = new Date();
console.log(now.getTimezoneOffset(), 'default');
['America/Costa_Rica', 'EST', 'America/St_Johns', 'UTC', 'America/Vancouver', 'Australia/Adelaide'].forEach(
(tz) => {
process.env.TZ = tz;
console.log(now.getTimezoneOffset(), tz);
}
);
```
```txt
360 default
360 America/Costa_Rica
300 EST
150 America/St_Johns
0 UTC
420 America/Vancouver
-570 Australia/Adelaide
```
Looks like feature not implemented?
Contributor guide
Assessment
This issue has not been assessed yet.