denoland / denoland/std

Setting Environment variable TZ does not affect Date.getTimezoneOffset()

Open
#6,091 0 comments 0 reactions 0 assignees View on GitHub
bug needs triage
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.