Closed IkerrSC closed 5 years ago
I have observe the same. Also in the timevis demo website appears this bug: https://daattali.com/shiny/timevis-demo/
When you move an Item, the time that appears in timeline and the time that appears on table are different. I attach a descriptive capture:
Thanks for the report.
I've found the source of the problem. R automatically converts the time stamps to UTC , while the time shown on the widget is local time.
The solution would be to allow the user to set a preferred timezone, and if a preferred timezone is given then all start
and end
values should be converted to the given timezone.
I'm not an expert in dealing with timezone issues, but this line of code is the best I could come up with to resolve this:
timevis_tz <- "America/Los_Angeles"
test_time <- "2016-01-10T06:00:00.000Z"
lubridate::with_tz(as.POSIXct(test_time), timevis_tz)
If anyone wants to fix this issue and submit a PR, I'd be happy to review and merge.
After looking into it some more, I don't think this is something that can or should be fixed. Timevis correctly returns the dates in a UTC timezone format, and that's ok. The end user can convert it to any other timezone if they wish to do so.
I just updated the app at https://daattali.com/shiny/timevis-demo/ using https://github.com/daattali/timevis/commit/cdfa832046df224924ec4a6e344fd2a39ae5ced6#diff-2ee94ad3267319f15acf63babaec8bf3 - there's unfortunately still going to be some discrepancy in that app for you if you're not in the same timezone as the app's server (EST), that's because the times in the widget are initialized on the client side, in javascript, so it will show up at 00:00 in the widget, and it will be treated as midnight in your timezone. But when R receives the data, as I said above, the timezone information is lost, it only receives the time based on UTC and it doesn't know what timezone you are in, so it converts it to the timezone the server is in, which is EST.
Looking the documentation on vis.js I have seen that you can set your timezone by using the options. For example,if you want to convert the timezone to UTC, you must write on vis.js this:
var options = {
moment: function(date) {
return vis.moment(date).utc();
}
};
But this I dont know how to implement it. I have tried with:
timevis(data,options=list(moment=function(date){..})
but this givee me an error.
Also I have trying to add this code on the timevis.js, but also not work.
I think that with this part of code, but well implemented, should work fine.
If I'm not mistaken, using moment
in visjs is an addition that happened after the version that is used in timevis. Every once in a while I test out the newest version of the javascript library to see if I can update timevis, but I keep finding bugs with it so I'm still on an old version that doesn't use moment
. I might be wrong, but that's what I seem to remember.
I think that moment is used on the version that you are using right now...
@jpara3 yes you're right, moment is indeed available, I'm not sure why I thought it wasn't! Allowing timezone changes can be a separate issue if you want to open one
I need to take the data returned from timevis, but these data are returned with one hour less then the data entered. I have tried changing the R time zone, but that has not solved the problem. here's a simple example of what I'm trying to do:
These are the data returned