1

How to manipulate values that are first generated by AnyTime 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.

corroded
  • 21,406
  • 19
  • 83
  • 132
Frane Novakovic
  • 55
  • 1
  • 2
  • 6

2 Answers2

3

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);
        }
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • That's it, thank you! Just a little note: thats not my line 1800. Version of my anytime.js is 4.1112 and I changed line 2912 to get this result. – Frane Novakovic Aug 12 '10 at 10:11
  • Great - I now posted more of the code surrounding the statement in case someone had a different version than what could find on the net. Note that my code needs a tweak if you want to handle users clicking a few seconds before or after the whole hour – mplungjan Aug 12 '10 at 11:46
1

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.

Andrew M. Andrews III
  • 1,989
  • 18
  • 23