function createDateAtMidnight(opt_value) {
      var date;
      if (angular.isDate(opt_value)) {
        date = opt_value;
      } else if (angular.isNumber(opt_value)) {
        date = new Date(opt_value);
      } else {
        date = new Date();
      }
      setDateTimeToMidnight(date);
      return date;
    }
Creates a date with the time set to midnight.
Drop-in replacement for two forms of the Date constructor via opt_value.
@param {number|Date=} opt_value Leave undefined for a Date representing now. Or use a
 single value representing the number of seconds since the Unix Epoch or a Date object.
@return {Date} New date with time set to midnight.