mirror of
https://github.com/nodejs/node.git
synced 2025-05-14 14:58:20 +00:00

The time zone output by toString() will change with user's language, use toLocaleString() to set the time zone. PR-URL: https://github.com/nodejs/node/pull/38741 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
38 lines
813 B
JavaScript
38 lines
813 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { isMainThread } = require('worker_threads');
|
|
|
|
if (!common.hasIntl)
|
|
common.skip('Intl not present.');
|
|
|
|
if (!isMainThread)
|
|
common.skip('Test not support running within a worker');
|
|
|
|
const assert = require('assert');
|
|
|
|
const cases = [
|
|
{
|
|
timeZone: 'Etc/UTC',
|
|
expected: /Coordinated Universal Time/,
|
|
},
|
|
{
|
|
timeZone: 'America/New_York',
|
|
expected: /Eastern (Standard|Daylight) Time/,
|
|
},
|
|
{
|
|
timeZone: 'America/Los_Angeles',
|
|
expected: /Pacific (Standard|Daylight) Time/,
|
|
},
|
|
{
|
|
timeZone: 'Europe/Dublin',
|
|
expected: /Irish/,
|
|
},
|
|
];
|
|
|
|
for (const { timeZone, expected } of cases) {
|
|
process.env.TZ = timeZone;
|
|
const date = new Date().toLocaleString('en-US', { timeZoneName: 'long' });
|
|
assert.match(date, expected);
|
|
}
|