How to manipulate values that are first generated by AnyTim开发者_JAVA百科e Picker? For example, I have an input field with AnyTime on it. When I click on that field, it gets populated with current time, and I want it to populate next round hour.
Try changing these lines of anytime.js
// Initialize the picker's date/time value.
try
{
this.time = this.conv.parse(this.inp.val());
this.offMin = this.conv.getUtcParseOffsetCaptured();
this.offSI = this.conv.getUtcParseOffsetSubIndex();
}
catch ( e )
{
this.time = new Date();
}
to
// Initialize the picker's date/time value.
try
{
this.time = this.conv.parse(this.inp.val());
this.offMin = this.conv.getUtcParseOffsetCaptured();
this.offSI = this.conv.getUtcParseOffsetSubIndex();
}
catch ( e )
{
this.time = new Date();
this.time.setHours(this.time.getHours()+1,0,0,0);
}
The picker uses the time in the field as the initial value, and only defaults to the current time if the field can't be parsed. The easiest way to initialize the picker is to fill the field with the start value you want, being sure that it's in the correct format.
精彩评论