Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Incorrect time shown in Node.js for timezone "Asia/Tehran" #4132

Closed
mostafa8026 opened this issue Mar 25, 2023 · 1 comment
Closed

Incorrect time shown in Node.js for timezone "Asia/Tehran" #4132

mostafa8026 opened this issue Mar 25, 2023 · 1 comment

Comments

@mostafa8026
Copy link

mostafa8026 commented Mar 25, 2023

Details

I am experiencing an issue with the timezone data in Node.js. Even though I have updated the tzdata package on my Ubuntu system, Node.js is still showing incorrect time for the Asia/Tehran timezone. I have checked that the system time on Ubuntu is correct, and I have also tested with the toLocaleString method in Node.js to verify that it is using the correct timezone name. However, the time displayed by Node.js is still off by +4.30 hours.

I have found that this issue was discussed in this GitHub issue (#1843) and it seems that Node.js obtains its timezone data from the ICU library, which is periodically updated with its own tzdata. I believe that this issue was fixed in Node.js v16.18.0 (nodejs/node#44283), but I am experiencing the issue in Node.js v14.17.3.

Node.js version

Node.js v14.17.3

Example code

const now = new Date();
const formatter = new Intl.DateTimeFormat('en-US', {
  timeZone: 'Asia/Tehran',
  timeZoneName: 'short'
});
const timezone = formatter.formatToParts(now).find(part => part.type === 'timeZoneName').value;
console.log(timezone); // GMT+4:30

It should be GMT+3:30

Operating system

uname -a
Linux mostafa-pc 6.0.0-x64v2-xanmod1 #0~20221003.git3325905 SMP PREEMPT_DYNAMIC Mon Oct 3 21:25:40 UT x86_64 x86_64 x86_64 GNU/Linux

Scope

Runtime

Module and version

No response

@mostafa8026
Copy link
Author

Closed as it's opened in incorrect place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant