thooyork / thooClock

jQuery analogue AlarmClock Plugin
MIT License
30 stars 17 forks source link

Wrong hourCorrection #13

Closed Finnb8r closed 6 years ago

Finnb8r commented 6 years ago

Hi, Great work and thanks for this clock ! It works great, but I have however noticed that with timezones that are over 9 hours offset, the hourCorrection is not working properly. This issue can be reproduced with an hourCorrection of 12 (Pacific/Nauru for example). The problem lies within the function numberCorrection on line 340 :

function numberCorrection(num){
    if(num !== '+0' && num !== ''){
        if(num.charAt(0) === '+'){
            //addNum
            return + num.charAt(1);
        }
        else{
            //subNum
            return - num.charAt(1);
        }
    }
    else{
        return 0;
    }
}

This will return 1 instead of 12. Fix would be to replace num.charAt(1) with num.substr(1) to return the correct number.

thooyork commented 6 years ago

Thanks for pointing that out ! Have fun with the clock plugin. If you use it on a public project a link or mention would be nice !