Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (TZ) => {
let winTz
let ianaTz
if (TZ !== 'UTC') {
winTz = ianaWin.findWindows(TZ)
ianaTz = ianaWin.findOneIana(TZ)
if (!winTz && !ianaTz) {
throw new Error(
`The timezone - ${TZ} - does not exist. Please provide a valid Windows or IANA time.`
)
}
}
if (os.platform() === 'win32') {
const previousTZ = execSync('tzutil /g').toString()
const cleanup = () => {
execSync(`tzutil /s "${previousTZ}"`)
console.log(`timezone was restored to ${previousTZ}`)
}
execSync(`tzutil /s "${winTz || TZ}"`)
console.warn(