trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

negative value in timepicker control #684

Open witiokz opened 10 years ago

witiokz commented 10 years ago

When timepicker is using with this configuration:

           controlType: myControl,
           timeOnly: true,
           timeFormat: 'hh:mm tt z',
           timezoneList: [
                   { value: 'EST', label: 'Eastern' },
                   { value: 'CST', label: 'Central' },
                   { value: 'MST', label: 'Mountain' },
                   { value: 'PST', label: 'Pacific' }
           ]
       });

and when user use spinner to select time and after that type "-" before that time value, value becomes negative. Please, see video and html in attacment (jpg should be renamed to zip).

htmlvideo

witiokz commented 10 years ago

could you update _onTimeChange method with this code:

        if (hour !== false) {
            hour = parseInt(hour, 10);
            hour = Math.abs(hour);
        }
        if (minute !== false) {
            minute = parseInt(minute, 10);
            minute = Math.abs(minute);
        }
        if (second !== false) {
            second = parseInt(second, 10);
            second = Math.abs(second);
        }
        if (millisec !== false) {
            millisec = parseInt(millisec, 10);
            millisec = Math.abs(millisec);
        }
        if (microsec !== false) {
            microsec = parseInt(microsec, 10);
            microsec = Math.abs(microsec);
        }

Thanks.