-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
tz = require("timezone/loaded");
date = "2015-12-14 14:30";
console.log(tz(date, "Europe/Berlin")); // correct timezone => correct result
console.log(tz(date, "Germany/Berlin")); // invalid timezone => returned UTC
console.log(tz(date, "Berlin")); // invalid timezone => returned UTC
console.log(tz(date, "Germany")); // invalid timezone => throws exceptionTypeError: Cannot read property 'rules' of undefined
at find (/test/node_modules/timezone/index.js:45:14)
at convertToPOSIX (/test/node_modules/timezone/index.js:76:29)
at Object.convert (/test/node_modules/timezone/index.js:180:23)
at /test/node_modules/timezone/index.js:209:41
at Object.<anonymous> (/test/example.js:8:13)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
For some incorrect timezones UTC time is returned, for some exception is thrown. I'm not sure what is desired behaviour (I would prefer stricter validation) but it should be definitely consistent. And the exception should said something more descriptive than Cannot read property 'rules' of undefined.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels