1-Month shift!

29 views
Skip to first unread message

black...@gmail.com

unread,
Feb 5, 2014, 10:14:31 AM2/5/14
to chap-link...@googlegroups.com
Hi,
I made a research on this group and I was surprised not to find anything about this, but it looks like there is a 1-month shift between the data sent to the script and thdata displayed.
For example, in the Offline Example, we can read that in the script:

d = new Date(2010, 9, 23, 20, 0, 0);
for (i = 0; i < 100; i++) {
   dataset1.data.push({
     'date': new Date(d),
     'value': functionA(i)
   });
 d.setMinutes(d.getMinutes() + 1);

So the wave should start the 23rd of September 2010 at 20:00 and then there is 1 point per minute, but when I look at the graph generated, it starts the 23rd of October!
This is quite problematic!

I am the only one to see this problem? Do you have any solution?
Thanks.

Raj Patel

unread,
Feb 5, 2014, 10:22:39 AM2/5/14
to chap-link...@googlegroups.com
new Date() takes month from 0.... So jan would be 0 and Oct would be 9.

black...@gmail.com

unread,
Feb 5, 2014, 10:33:31 AM2/5/14
to chap-link...@googlegroups.com
Ah! You saved my day :-)
I'm new to JS and this is the first time I see January = 0.
I found really weird that nobody noticed that :-D
Thanks!

Jos de Jong

unread,
Feb 5, 2014, 11:36:17 AM2/5/14
to chap-link...@googlegroups.com
well, actually you're far from the first :) 

Reply all
Reply to author
Forward
0 new messages