bigeasy / bigeasy/timezone

Exception for some invalid timezones

Open
#261 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
256
Forks
26
PR merge metrics
No merged PRs in 30d

Description

``` javascript
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. (/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`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the failing examples in test/example.js and trace the timezone lookup through index.js, especially find and convertToPOSIX. Compare the behavior for Germany/Berlin, Berlin, and Germany, then establish consistent invalid-timezone handling and a more descriptive failure message. Done means the examples behave consistently without the reported undefined-property exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.