var isValid = require('../is_valid')

/**
 * @category Common Helpers
 * @summary Is the date constructed from the given values exist?
 *
 * @description
 * Validates that the given values are within acceptable ranges,
 * e. g. the hour value should be within range [0..23], the second value within [0..59] etc.
 *
 * @param {Number} year - the year of the date
 * @param {Number} month - the month of the date
 * @param {Number} [day=1] - the day of the month of the date
 * @param {Number} [hours=0] - the hours of the date
 * @param {Number} [minutes=0] - the minutes of the date
 * @param {Number} [seconds=0] - the seconds of the date
 * @param {Number} [milliseconds=0] - the milliseconds of the date
 * @returns {Boolean} all values are valid
 *
 * @example
 * // For the existing date:
 * var result = isValidDateValues(new Date(2014, 1, 28, 12, 0))
 * //=> true
 *
 * @example
 * // For the impossible date (29 February of non-leap year):
 * var result = isValidDateValues(new Date(2014, 1, 29, 12, 0))
 * //=> false
 */
var isValidDateValues = function(year, month, day, hours, minutes, seconds, milliseconds) {
  if (year >= 0 && year < 100) {
    year = 1900 + year
  }

  day = day || 1
  hours = hours || 0
  minutes = minutes || 0
  seconds = seconds || 0
  milliseconds = milliseconds || 0

  var date = new Date(year, month, day, hours, minutes, seconds, milliseconds)

  return isValid(date)
    && date.getFullYear() == year
    && date.getMonth() == month
    && date.getDate() == day
    && date.getHours() == hours
    && date.getMinutes() == minutes
    && date.getSeconds() == seconds
    && date.getMilliseconds() == milliseconds
}

module.exports = isValidDateValues


@@ -817,33 +817,24 @@
 dDateValues(
-new Date(
 2014, 1, 28,
@@ -832,33 +832,32 @@
 4, 1, 28, 12, 0)
-)
 %0A * //=%3E true%0A *
@@ -965,25 +965,16 @@
 eValues(
-new Date(
 2014, 1,
@@ -984,17 +984,16 @@
 , 12, 0)
-)
 %0A * //=%3E

Fix @example of isValidDateValues