Open Svjard opened 11 years ago
Is there some way to "upvote" this?
I have the same issue and it would be great to be able to optionally pass an argument to set time zone for display. Best? The best would be to just say where you are, something like "CET" or "EST+1" and that would magically set the right offset through the use of some lookup table for constants.
Please use Rickshaw.Fixtures.Time / Rickshaw.Fixtures.Time.Local wherever you need to fix timezone related issues. For eg: var x_axis = new Rickshaw.Graph.Axis.Time({ graph: graph, timeFixture: new Rickshaw.Fixtures.Time.Local() });
While very elegant, the existing system doesn't seem to allow displaying the x axis unix timestamps using whatever time zone is appropriate (browser time zone for example).
It ends up using (for hour formatting) something like this:
new Date(1350425400*1000).toUTCString().match(/(\d+:\d+):/)[1]
See also https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Fixtures.Time.js#L5 -- this tzOffset variable isn't being used anywhere.
We actually ran into this problem recently, and we forked the repo to include time zone offset. You can check out the code here: https://github.com/alphaboost/rickshaw/blob/master/src/js/Rickshaw.Graph.Axis.Time.js
Basically, we added an argument to the Rickshaw.Graph.Axis.Time.js, which should be the time zone offset from UTC (i.e. -7 for PDT) * the number of seconds in an hour (3600, since Rickshaw uses seconds instead of milliseconds).
The code isn't quite ready for a pull request on Rickshaw, but it did the trick for us. When we have time to polish it up we'll drop it on a pull.