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

Exception for some invalid timezones #261

Open
MartinMajor opened this issue Dec 14, 2015 · 0 comments
Open

Exception for some invalid timezones #261

MartinMajor opened this issue Dec 14, 2015 · 0 comments

Comments

@MartinMajor
Copy link

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 exception
TypeError: 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.

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