deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

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

Open jpravetz opened this issue 1 year ago • 0 comments

Datetime timezoneoffset has not been implemented?

Run this script with deno (can use process.env.TZ or Deno.env.set method):

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:

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:

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);
  }
);
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?

jpravetz avatar Oct 04 '24 20:10 jpravetz