Closed markus-oehme-xceptance closed 12 years ago
Can you specify your use case or be more detailed? Are you trying to convert 1 date to another or initialize a timezoneJS.Date
?
Ok, here we go: On the high level I create a flot graph with a time axis, which has a timezone attached to it (this only works with a development snapshot). The result is, that the time axis has no ticks because the time gets messed up.
Here is what it does in the internals: flot creates a timezoneJS.Date d [1] afterwards it does something like d.setMinutes(d.getMinutes()) which turns out to be not a nop, but shifts the time by the timezone offset. If I apply my magic fix, the code works as a nop as expected.
[1] The creation of the timezoneJS.Date is done with the following code in the official repository:
var d = new timezoneJS.Date(); // timezone-js is fickle, so be sure to set the time zone before // setting the time. d.setTimezone(opts.timezone); d.setTime(ts); return d;
I had to change it to
return new timezoneJS.Date(ts, opts.timezone);
to work reliably. The latter code is what I tested against and which exhibited the behavior described above.
You can do:
var d = new timezoneJS.Date(ts, 'Etc/UTC');
d.setTimezone(opts.timezone);
return d;
It does seem to be an issue. I'll take a look at it. In the mean time you can do d.setUTCMinutes(d.getUTCMinutes())
I want to use the new timezone-support in flot master branch (which uses timezone-js as backend). Unfortunately this doesn't work out of the box for me. I need to apply the following patch to timezone-js and then (with another patch to flot, see http://code.google.com/p/flot/issues/detail?id=713) everything works fine.
The patch seems wrong to me in the sense that I'm trampling the semantics, but it Works For Me(tm).
Here comes the patch (why dosn't github allow attachments?):