Daylight Saving Time error in Javascript

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Daylight Saving Time error in Javascript

Re: Daylight Saving Time error in Javascript

Post by joedf » 26 Oct 2014, 14:07

Is there a JavaScript or is it that it doesn't support dst?

Daylight Saving Time error in Javascript

Post by zcooler » 26 Oct 2014, 13:09

hi!

I have a javascript that behaves peculiar around DST changes. The error manifest itself by the TV EPG cannot toggle (with navigate button) past the day of the DST change. For example today Sunday 26:th of October where the DST changes.
Trying to navigate to Mondays EPG is impossible. Each button press reloads Sundays EPG. Somehow it seems the javascript code simply adds 24 hours, which doesn't work in this case, because Sunday comprises 25 hours due to the DST change.

Code: Select all

var ONE_DAY = 24*60*60*1000;
 
Line 686:
 
    /**
     * increments or decrements the date in the datepicker by the given amount
     */
    function moveDate(offset) {
        var currDate = datefield.datepicker("getDate");
        currDate.setTime(currDate.getTime() + offset * ONE_DAY);
        var now = new Date().getTime();
        if (currDate.getTime() + 2*ONE_DAY < now || currDate.getTime() - 31*ONE_DAY > now) {
            return;
        }
        datefield.datepicker("setDate", currDate);
        guiactionform.submit();
    }
 
Line 1298:
 
        $('#nextday').click(function() {
            moveDate(+1);
        });
Something in the javascript date object seems wrong. Maybe there are some programmers in here familiar with javascript who might wanna have a look? If such a case pm me and I will post the full javascript to ya.

Regards
zcooler

Top