1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4 5if (!common.isMainThread) 6 common.skip('process.env.TZ is not intercepted in Workers'); 7 8if (common.isWindows) // Using a different TZ format. 9 common.skip('todo: test on Windows'); 10 11const date = new Date('2018-04-14T12:34:56.789Z'); 12 13process.env.TZ = 'Europe/Amsterdam'; 14 15if (date.toString().includes('(Europe)')) 16 common.skip('not using bundled ICU'); // Shared library or --with-intl=none. 17 18if ('Sat Apr 14 2018 12:34:56 GMT+0000 (GMT)' === date.toString()) 19 common.skip('missing tzdata'); // Alpine buildbots lack Europe/Amsterdam. 20 21if (date.toString().includes('(Central European Time)') || 22 date.toString().includes('(CET)')) { 23 // The AIX and SmartOS buildbots report 2018 CEST as CET 24 // because apparently for them that's still the deep future. 25 common.skip('tzdata too old'); 26} 27 28// Text representation of timezone depends on locale in environment 29assert.match( 30 date.toString(), 31 /^Sat Apr 14 2018 14:34:56 GMT\+0200 \(.+\)$/); 32 33process.env.TZ = 'Europe/London'; 34assert.match( 35 date.toString(), 36 /^Sat Apr 14 2018 13:34:56 GMT\+0100 \(.+\)$/); 37 38process.env.TZ = 'Etc/UTC'; 39assert.match( 40 date.toString(), 41 /^Sat Apr 14 2018 12:34:56 GMT\+0000 \(.+\)$/); 42 43// Just check that deleting the environment variable doesn't crash the process. 44// We can't really check the result of date.toString() because we don't know 45// the default time zone. 46delete process.env.TZ; 47date.toString(); 48