Permalink
Browse files

Timepicker: Fixing up from 23 to go to 0 instead of 12

  • Loading branch information...
1 parent 3a7693d commit 98df01430ac46d5330bf2191b0970d1c34c58889 @gnarf gnarf committed Sep 28, 2011
Showing with 12 additions and 3 deletions.
  1. +11 −2 tests/unit/timepicker/timepicker_events.js
  2. +1 −1 ui/jquery.ui.timepicker.js
@@ -9,15 +9,16 @@ function downup( elem, key ) {
}
test( "keydown: Up/Down/Left/Right behaviors", function() {
- expect( 11 );
+ expect( 12 );
var i,
input = $( "#timepicker1" ).val( "12:00:00 PM" ).timepicker(),
timepicker = input.data( "timepicker" ),
mask = timepicker.mask;
mask._caret( 0, 0 );
- equal( input.val(), "12:00:00 PM", "Sanity Check" );
+ mask._caret( 0, 0 );
+ timepicker._setField( 0 );
deepEqual( mask._caret(), { begin: 0, end: 0 }, "Caret position correct" );
downup( input, $.ui.keyCode.UP );
@@ -47,6 +48,14 @@ test( "keydown: Up/Down/Left/Right behaviors", function() {
downup( input, $.ui.keyCode.DOWN );
equal( input.val(), "11:50:00 AM", "After down keypress in am/pm field, value went to proper value" );
+ input.timepicker( "destroy" ).val( "23:00:00" ).timepicker({ ampm: false });
+ timepicker = input.data( "timepicker" );
+ timepicker._setField( 0 );
+ equal( input.val(), "23:00:00", "Sanity Check" );
+
+ downup( input, $.ui.keyCode.UP );
+ equal( input.val(), " 0:00:00", "After up keypress in hours field, value went to proper value" );
+
});
@@ -237,7 +237,7 @@ $.widget( "ui.timepicker", {
if ( this.currentField === ( this.options.seconds ? 3 : 2 ) ) {
val = getAmPmArrays()[ parseInt( val, 10 ) ? "pm" : "am" ][ 0 ];
}
- bufferObject.value = bufferObject.valid( val );
+ bufferObject.value = bufferObject.valid( val + "" );
this.mask._paint();
this.spinner._refresh();
this.mask._caretSelect( this.currentField * 3 );

0 comments on commit 98df014

Please sign in to comment.