Skip to content

TZ env var doesn't work on Windows #31478

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jkellyinsf opened this issue Jan 23, 2020 · 4 comments
Closed

TZ env var doesn't work on Windows #31478

jkellyinsf opened this issue Jan 23, 2020 · 4 comments
Labels
i18n-api Issues and PRs related to the i18n implementation. v8 engine Issues and PRs related to the V8 dependency. windows Issues and PRs related to the Windows platform. wontfix Issues that will not be fixed.

Comments

@jkellyinsf
Copy link

  • Version: 13.7.0 (also repro'd on 13.6.0)
  • Platform: Windows 10 64 bit
  • Subsystem: putil.cpp

I wrote this modest test file date.js that shows how the TZ env var is set and what time zone dates are using.

console.log(`node platform ${process.platform}, version ${process.version}`)
console.log(`process.env.TZ = ${process.env.TZ}`)
console.log(`default date ${new Date().toString()}, offset = ${new Date().getTimezoneOffset()}`)

My machine is in Pacific Time. When I override the TZ to UTC and run this script through the linux build of node (on Ubuntu under WSL), I get the UTC dates I expect:

$ TZ=UTC node date.js  
node platform linux, version v13.7.0                                                    
process.env.TZ = UTC                                                                    
default date Thu Jan 23 2020 14:54:15 GMT+0000 (Coordinated Universal Time), offset = 0 

When I run it with the Windows build, process.env.TZ claims to be in UTC, but dates still come out in Pacific Time.

# set TZ=UTC && node date.js
node platform win32, version v13.7.0                                                  
process.env.TZ = UTC                                                                  
default date Thu Jan 23 2020 06:54:30 GMT-0800 (Pacific Standard Time), offset = 480  
@addaleax addaleax added v8 engine Issues and PRs related to the V8 dependency. windows Issues and PRs related to the Windows platform. i18n-api Issues and PRs related to the i18n implementation. labels Jan 23, 2020
@addaleax
Copy link
Member

/cc @nodejs/intl

@bnoordhuis
Copy link
Member

I'm fairly sure #4230 (comment) is still the current state of things. That means TZ is ignored on Windows.

You can change the timezone with tzutil but that's a system-wide change, of course.

@sxa
Copy link
Member

sxa commented Jan 24, 2020

Unless there was something to actively set that on Windows, we're talking about a UNIX-specific variable so I would agree with @bnoordhuis - there's no reason why it would generally be interpreted by processes on Windows. If it was to be processed on non-UNIX based platforms, there would likely need to be a handler within Node.js itself to interpret all of the values in there to map all of the potential values of TZ to something meaningful - I haven't checked the code but I assume Node is currently calling into the OS to do the time zone translation.

@bnoordhuis
Copy link
Member

I'll close this out as (not-)working-as-expected.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
i18n-api Issues and PRs related to the i18n implementation. v8 engine Issues and PRs related to the V8 dependency. windows Issues and PRs related to the Windows platform. wontfix Issues that will not be fixed.
Projects
None yet
Development

No branches or pull requests

4 participants