Issue 1421: minTime/maxTime floats
Status:  Invalid
Owner: ----
Closed:  Aug 2013
Reported by koosvdk...@gmail.com, May 29, 2012
Currently it is only possible to use integers (0-23) or strings ("5:00am") to set the minTime/maxTime. 

I would like to be able to add floats, e.g. 5.5 for "5:30am".

Furthermore, a function as below would be nice:

/**
    * Helper function: Converts a given time to a float, e.g. '8:15' becomes 8.25
    * @param mixed time A integer, float or a string. Valid strings: '8:15', '20:15', '8:15am', '8:15pm', '8.15', etc.
    * @license http://opensource.org/licenses/gpl-license.php GNU Public License
    * @author Koos van der Kolk <koosvdkolk@gmail.com>
    * @return float
    **/
    function timeToFloat(time) {      
      var returnValue, timeAsArray, separator, i, timeSeparators = [':', '.'], numberOfSeparators;

      /* is time an integer or a float? */
      if (parseInt(time, 10) === time || parseFloat(time) === time) {
        returnValue = time;
      } else {
        /* time will be considered a string, parse it */
        time = time.toString();

        numberOfSeparators = timeSeparators.length;

        for (i = 0; i < numberOfSeparators; i = i + 1) {
          separator = timeSeparators[i];

          if (time.indexOf(separator) > 0) {
            timeAsArray = time.split(separator);

            returnValue = parseInt(timeAsArray[0], 10) + parseInt(timeAsArray[1], 10) / 60;

            /* does string contain 'p' or 'pm'? */
            if (time.indexOf('p') > 0 && returnValue <= 12) {
              returnValue = returnValue + 12;
            }
          }
        }
      }
      return returnValue;
    }
Aug 18, 2013
Project Member #1 adamrs...@gmail.com
(No comment was entered for this change.)
Status: Invalid