Closed jacobbubu closed 10 years ago
Any more details?
We just solved this locally here at Cengage Learning, and would like to share the solution. This is an error with the parser not ignoring whole-line comments in the zonefiles that are indented (6 leading tabs, then a hash + comment with no Zone or Rule) We can push up a fix. (At least this is a similar exception that we ran into processing Europe/Athens & Antarctica/Casey - "Cannot read property '1' of null")
Yeah definitely submit a PR :) Please make sure you have unit tests w/ it also. Thanks!! :+1:
Noticing now that you'd fixed it, albeit differently then we have (turns out we're using a dated version here). We may throw up our version of the fix so you can see if you'd like it better, but we'll also be looking at updating our implementation.
Thanks!
From: Long Ho notifications@github.com<mailto:notifications@github.com> Reply-To: mde/timezone-js reply@reply.github.com<mailto:reply@reply.github.com> Date: Tuesday, August 13, 2013 2:03 PM To: mde/timezone-js timezone-js@noreply.github.com<mailto:timezone-js@noreply.github.com> Cc: "Mastroianni, Tony" Tony.Mastroianni@cengage.com<mailto:Tony.Mastroianni@cengage.com> Subject: Re: [timezone-js] Exception occurred when using pre-parsed JSON data with timezone 'Europe/Chisinau' and the date '1969-12-31T16:00:00.000Z' (#88)
Yeah definitely submit a PR :) Please make sure you have unit tests w/ it also. Thanks!! [:+1:]
— Reply to this email directly or view it on GitHubhttps://github.com/mde/timezone-js/issues/88#issuecomment-22584922.
Cool, would love to merge the 2
Hi, have you posted solution for this? i m getting the same error?
Hi, I'm still experiencing the same error for certain time zones as well. Specifically: Europe/Chisinau Europe/Kaliningrad Europe/Kiev Europe/Minsk Europe/Moscow Europe/Riga Europe/Simferopol Europe/Tallinn Europe/Uzhgorod Europe/Vilnius Europe/Zaporozhye
I tried to debug the issue, but the only conclusion I was able to come to is that the rules for "Russia" couldn't be read/parsed properly.
Are you using it w/ the pre-parsed JSON?
In order to proceed w/ this issue can someone throw a simple test case up? :) Thanks
I'm using timezone-js in Node:
/* Test code */
var fs = require('fs'),
path = require('path'),
tzJS = require('timezone-js');
tzJS.timezone.transport = function (opts) {
// No success handler, what's the point?
if (opts.async) {
if (typeof opts.success !== 'function') {
return;
}
opts.error = opts.error || console.error;
return fs.readFile(opts.url, 'utf8', function (err, data) {
return err ? opts.error(err) : opts.success(data);
});
}
return fs.readFileSync(opts.url, 'utf8');
};
tzJS.timezone.zoneFileBasePath = path.join(__dirname, 'resources/tz');
tzJS.timezone.defaultZoneFile = ['backward', 'etcetera', 'europe', 'northamerica'];
tzJS.timezone.init({ async: false });
var parisTime = new tzJS.Date(1969, 6, 21, 2, 56, 'Europe/Paris');
console.log('Paris time:');
console.log(parisTime);
console.log('Paris timezone:');
console.log(parisTime.getTimezoneInfo());
console.log('---');
var moscowTime = new tzJS.Date(1969, 6, 21, 2, 56, 'Europe/Moscow');
console.log('Moscow time:');
console.log(moscowTime);
console.log('Moscow timezone:');
console.log(moscowTime.getTimezoneInfo());
Output:
Paris time:
{ _useCache: false,
_tzInfo: {},
_day: 1,
year: 1969,
month: 6,
date: 21,
hours: 2,
minutes: 56,
seconds: 0,
milliseconds: 0,
timezone: 'Europe/Paris',
_dateProxy: Mon Jul 21 1969 02:56:00 GMT-0700 (Pacific Daylight Time),
_timeProxy: -14159040000 }
Paris timezone:
{ tzOffset: -60, tzAbbr: 'CEST' }
---
Moscow time:
{ _useCache: false,
_tzInfo: {},
_day: 1,
year: 1969,
month: 6,
date: 21,
hours: 2,
minutes: 56,
seconds: 0,
milliseconds: 0,
timezone: 'Europe/Moscow',
_dateProxy: Mon Jul 21 1969 02:56:00 GMT-0700 (Pacific Daylight Time),
_timeProxy: -14159040000 }
Moscow timezone:
...<snip>...\node_modules\timezone-js\src\date.js:839
return base.split("/", 2)[rule[6] ? 1 : 0];
^
TypeError: Cannot read property '6' of null
at getAbbreviation (...<snip>...\node_modules\timezone-js\src\date.js:839:39)
at getTzInfo (...<snip>...\node_modules\timezone-js\src\date.js:1004:18)
at Object.timezoneJS.Date.getTimezoneInfo (...<snip>...\node_modules\timezone-js\src\date.js:287:33
)
at Object.<anonymous> (...<snip>...\test.js:34:24)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
Thanks this definitely helps :) I'll try to take a look asap.
1 more quick question, this issue occurs in the latest version 0.4.7?
No, I'm on timezone-js 0.4.6, Node.js version 0.10.15, and I downloaded the timezone files about a week ago? Thanks for looking into it!
Can you try 0.4.7?
Oh nice! That seemed to have done the trick. :) Thanks a lot!
Moscow time:
{ _useCache: false,
_tzInfo: {},
_day: 1,
year: 1969,
month: 6,
date: 21,
hours: 2,
minutes: 56,
seconds: 0,
milliseconds: 0,
timezone: 'Europe/Moscow',
_dateProxy: Mon Jul 21 1969 02:56:00 GMT-0700 (Pacific Daylight Time),
_timeProxy: -14159040000 }
Moscow timezone:
{ tzOffset: -180, tzAbbr: 'MSK' }
Cool we did fix some parsing issue :). Closing this ticket
TypeError: Cannot read property '6' of null at getAbbreviation (/Users/shenrong/Dropbox/Temporary/timezonetest/node_modules/timezone-js/src/date.js:723:38) at [object Object].getTzInfo (/Users/shenrong/Dropbox/Temporary/timezonetest/node_modules/timezone-js/src/date.js:889:18) at Object.timezoneJS.Date.getTimezoneInfo (/Users/shenrong/Dropbox/Temporary/timezonetest/node_modules/timezone-js/src/date.js:243:33) at Object.timezoneJS.Date.getTimezoneOffset (/Users/shenrong/Dropbox/Temporary/timezonetest/node_modules/timezone-js/src/date.js:234:50)