supasympa
10/2/2014 - 3:28 PM

SimpleDateFormatToTicks

    /**
     * gets the number of milliseconds from a date using a date format.
     * @param dateString : the date to convert
     * @param format : the format the date is in
     * @returns Milliseconds from 01/01/1970 
     */
    return function (dateString, format){
      function getDatePart(part){
        var re, start, end;

        re = new RegExp(part);
        start = re.exec(format).index;
        end = start + part.length;

        return dateString.substring(start, end)
      };

      return (new Date(+getDatePart('yyyy'), +getDatePart('mm'), +getDatePart('dd'))).valueOf();
    };