Daylight Saving Time error in Javascript

Discuss other programming languages besides AutoHotkey
zcooler
Posts: 455
Joined: 11 Jan 2014, 04:59

Daylight Saving Time error in Javascript

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
User avatar
joedf
Posts: 8953
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Daylight Saving Time error in Javascript

26 Oct 2014, 14:07

Is there a JavaScript or is it that it doesn't support dst?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 35 guests