Mahesh Reddy
Mahesh Reddy

Reputation: 356

timepicker does't allow hourMax value more than 99

If I keep the hourMax more than 99 only last two digits are taken as hourMax value. Ex: if hourMax:139 it's allowing upto 39.

if you want to check then in script tab Change the hourMax in the following link to 139 & run there. demo

Upvotes: 0

Views: 1060

Answers (2)

sontae
sontae

Reputation: 1

You can play with the microseconds and milliseconds to do the trick.

For example :

$(".timepicker").timepicker({
    addSliderAccess : true,
    millisecText:"Hours",
    microsecText:"Minutes",
    timeFormat:"l:c",
    showHour:false,
    showMinute:false,
    showMicrosec:true,
    showMillisec:true,          
    millisecMax:999,
    microsecMax:55,
    stepMillisec:1,
    stepMicrosec: 5,
    microsecGrid: 10,                       
    sliderAccessArgs : {
        touchonly : false
    }
}); 

You will have by the way to extend the plugins function $.datepicker.formatTim to correctly format the "fake" hours and minutes, which are here replaced by Microseconds and Milliseconds.

EXTENDED THE PLUGIN :

/*HERE IS THE OVERRIDE OF THE TIMEPICKER FUNCTION, 
YOU CAN PUT THIS INTO A CUSTOM FOLDER AND FILE AND 
CALL IMPLEMENT IT AFTER THE jquery-ui-timepicker.addon.js 
like jquery-ui-timepicker.addon.custom.js for example*/

(function ($) {
    $.datepicker.formatTime= function (format, time, options) {
        options = options || {};
        options = $.extend({}, $.timepicker._defaults, options);
        time = $.extend({
            hour: 0,
            minute: 0,
            second: 0,
            millisec: 0,
            microsec: 0,
            timezone: null
        }, time);

        var tmptime = format,
            ampmName = options.amNames[0],
            hour = parseInt(time.hour, 10);

        if (hour > 11) {
            ampmName = options.pmNames[0];
        }

        tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
            switch (match) {
            case 'HH':
                return ('0' + hour).slice(-2);
            case 'H':
                return hour;
            case 'hh':
                return ('0' + convert24to12(hour)).slice(-2);
            case 'h':
                return convert24to12(hour);
            case 'mm':
                return ('0' + time.minute).slice(-2);
            case 'm':
                return time.minute;
            case 'ss':
                return ('0' + time.second).slice(-2);
            case 's':
                return time.second;
            case 'l':
                return ('0' + time.millisec).slice(-3);
            case 'c':
                return ('0' + time.microsec).slice(-2);
            case 'z':
                return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, false);
            case 'Z':
                return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, true);
            case 'T':
                return ampmName.charAt(0).toUpperCase();
            case 'TT':
                return ampmName.toUpperCase();
            case 't':
                return ampmName.charAt(0).toLowerCase();
            case 'tt':
                return ampmName.toLowerCase();
            default:
                return match.replace(/'/g, "");
            }
        });
        return tmptime;
    };
})(jQuery);

Enjoy.

Upvotes: 0

neuhaus
neuhaus

Reputation: 4094

timepicker (as the name implies) is designed to pick a time of day (i.e. usually between 0 and 23 hours), not a time interval. Perhaps you should look at jQuery Time Entry. It has an example "unlimited hours" under "Formats".

Upvotes: 2

Related Questions