Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

[Timeline regression bug] Using a simple date string has timezone issues in 4.21 #3851

Open
daattali opened this issue Mar 2, 2018 · 3 comments

Comments

@daattali
Copy link
Contributor

daattali commented Mar 2, 2018

At some point between 4.16.1 and 4.21, using a simple string such as "2018-03-01" started acting a bit strange. The event shows up a bit before the date instead of on the actual date.

Here's a minimal HTML code to reproduce:

<!DOCTYPE HTML>
<html>
<head>
  <script src="vis-4.16.1/vis.min.js"></script>
  <link href="vis-4.16.1/vis.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="visualization"></div>
<script type="text/javascript">
  var container = document.getElementById('visualization');
  var items = [{id: 1, content: 'item 1', start: '2013-04-20'}]
  var timeline = new vis.Timeline(container, items, {});
</script>
</body>
</html>

Running this with visjs 4.16.1 looks fine:

image

Notice that the event line is exactly on the line where the 20th starts.

But using timevis 4.21 I get this:

image

Notice that now the event is pinned to a bit before the 20th. I realize I can probably change my javascript code to account for timezones, but I've ported this library to R (and it's quite popular), so people are simply writing date strings in R and they get passed down to visjs, and it would suck to have to tell everyone to change their code.

@daattali
Copy link
Contributor Author

daattali commented Mar 2, 2018

It looks like it's auto-adjusting to my timezone, because it's going back 5 hours and I'm at UTC-5

@KalasinSeymour
Copy link

I can confirm that this change happened before 4.19.1, though I can't exactly say in which version it happened because that's the oldest version of the library I could find in my archive. I found some hints that it might happened in 4.19.0 or 4.18.0 but I can't say for sure without testing those versions. At least that issue should be easily fixed by defining your own moment constructor.

@daattali
Copy link
Contributor Author

cross posted at yotamberk/timeline-plus#100

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants