Check if this is a legal date in the Gregorian calendar
352047
def legal_date(year, month, day):
    ''''''
    if month == 2:
        daysinmonth = 29 if isleap(year) else 28
    else:
        daysinmonth = 30 if month in HAVE_30_DAYS else 31

    if not (0 < day <= daysinmonth):
        raise ValueError("Month {} doesn't have a day {}".format(month, day))

    return True
697911
def isworkday(self, date):
        
        date = parsefun(date)
        return self.weekdaymap[date.weekday()].isworkday
436962
def match_date(self, value, strict=False):
        """"""
        value = stringify(value)
        try:
            parse(value)
        except Exception:
            self.shout('Value %r is not a valid date', strict, value)
536354
function getValidDate (y, m, d, h, i, s, ms) {
  var date = new Date(y, m - 1, d, h, i, s, ms);
  if (
      y  === date.getFullYear()  &&
      m  === date.getMonth() + 1 &&
      d  === date.getDate()      &&
      h  === date.getHours()     &&
      i  === date.getMinutes()   &&
      s  === date.getSeconds()   &&
      ms === date.getMilliseconds()
  ) {
    return date;
  } else {
    return null;
  }
}
514816
function isValid(date) {
  return Object.prototype.toString.call(date) == '[object Date]' && !isNaN(date.getTime());
}
420030
public static function is($date)
    {
        if (is_bool($date) || empty($date) xor ($date === 0 || $date === '0')) {
            return false;
        }
        $date = static::isTimestamp($date) ? '@' . (string)$date : $date;
        return (bool)date_create($date);
    }
1275770
private static String boundTimestamp(String input) {
		StringBuilder boundTimestamp = new StringBuilder();
		
		if (input == null) {
			input = "";
		}
		// MAKE SURE THE YEAR IS WITHIN LEGAL BOUNDARIES:
		boundTimestamp.append(boundDigits(input.substring(0,4),
				YEAR_LOWER_LIMIT, 
                                String.valueOf(Calendar.getInstance(TimeZone.getTimeZone("GMT")).get(Calendar.YEAR) )));

		// MAKE SURE THE MONTH IS WITHIN LEGAL BOUNDARIES:
		boundTimestamp.append(boundDigits(input.substring(4,6),
				MONTH_LOWER_LIMIT,MONTH_UPPER_LIMIT));
		
		// NOW DEPENDING ON THE YEAR + MONTH, MAKE SURE THE DAY OF MONTH IS
		// WITHIN LEGAL BOUNDARIES:
		int iYear = Integer.parseInt(boundTimestamp.substring(0,4));
		int iMonth = Integer.parseInt(boundTimestamp.substring(4,6));
		String maxDayOfMonth = getDaysInMonthBound(iYear, iMonth-1);

		boundTimestamp.append(boundDigits(input.substring(6,8),
				DAY_LOWER_LIMIT,maxDayOfMonth));
		
		// MAKE SURE THE HOUR IS WITHIN LEGAL BOUNDARIES:
		boundTimestamp.append(boundDigits(input.substring(8,10),
				HOUR_LOWER_LIMIT,HOUR_UPPER_LIMIT));
		
		// MAKE SURE THE MINUTE IS WITHIN LEGAL BOUNDARIES:
		boundTimestamp.append(boundDigits(input.substring(10,12),
				MINUTE_LOWER_LIMIT,MINUTE_UPPER_LIMIT));
		
		// MAKE SURE THE SECOND IS WITHIN LEGAL BOUNDARIES:
		boundTimestamp.append(boundDigits(input.substring(12,14),
				SECOND_LOWER_LIMIT,SECOND_UPPER_LIMIT));

		return boundTimestamp.toString();		
	}
330137
private static boolean isIMMMonth(final Calendar cal) {
        final int month = cal.get(MONTH);

        switch (month) {
        case MARCH:
        case JUNE:
        case SEPTEMBER:
        case DECEMBER:
            return true;
        default:
            return false;
        }
    }
314769
def _is_valid_date_time(self, inpt, metadata):
        """"""
        # NEED TO ADD CHECKS FOR OTHER METADATA, LIKE MINIMUM, MAXIMUM, ETC.
        from dlkit.abstract_osid.calendaring.primitives import DateTime as abc_datetime
        if isinstance(inpt, abc_datetime):
            return True
        else:
            return False
539801
def valid_date(key, config_date):
    
    key_date = "/".join(key.split("/")[4:7])
    return parse_date(key_date) > parse_date(config_date)
1095493
def is_holiday(self, date):
        
        time = [
            date.year,
            date.month,
            date.day,
            date.isoweekday(),
            _extract_week_number(date)
        ]

        target = []
        for key, data in list(zip(TIME_LABEL, time)):
            d = getattr(self, key)
            asterisk = d.get("*", set())
            s = asterisk.union(d.get(data, set()))
            target.append(list(s))

        for result in map(set, product(*target)):
            if len(result) == 1:
                return True
        return False
128255
public static boolean isDateInThePast(final Date date)
	{
		boolean inPast = false;
		final Calendar compare = Calendar.getInstance();
		compare.setTime(date);
		final Calendar now = Calendar.getInstance();
		now.setTime(new Date(System.currentTimeMillis()));
		inPast = now.after(compare);
		return inPast;
	}
982201
static function isValidISODateString( $sDate )
	{
		if ( ! CLib::IsExistingString( $sDate ) )
		{
			return false;
		}

		$nTime	= strtotime( $sDate );
		return ( false !== $nTime &&
			0 == strcasecmp( $sDate, date( "Y-m-d", $nTime ) ) );
	}
321411
private void parseAmbiguousDatesAsAfter(Date startDate) {
        defaultCenturyStart = startDate;
        calendar.setTime(startDate);
        defaultCenturyStartYear = calendar.get(Calendar.YEAR);
    }
452543
def onOffset(self, date):
        """"""
        mod_month = (date.month - self.month) % 3
        return mod_month == 0 and date.day == self._get_offset_day(date)
996624
function gregorianToJDN(year = 1, month = 1, day = 1, JD_OFFSET = JD_EPOCH_OFFSET_GREGORIAN) {
  const s = Math.floor(year / 4)
          - Math.floor((year - 1) / 4)
          - Math.floor(year / 100)
          + Math.floor((year - 1) / 100)
          + Math.floor(year / 400)
          - Math.floor((year - 1) / 400);
  const t = Math.floor((14 - month) / 12);
  const n = 31 * t * (month - 1)
          + (1 - t) * (59 + s + 30 * (month - 3) + Math.floor((3 * month - 7) / 5))
          + day - 1;
  const j = JD_OFFSET
          + 365 * (year - 1)
          + Math.floor((year - 1) / 4)
          - Math.floor((year - 1) / 100)
          + Math.floor((year - 1) / 400)
          + n;

  return j;
}
296817
def check_time_param(t):
    """"""

    if type(t) is str:
        if not ISO.match(t):
            raise ValueError('Date string "%s" does not match ISO8601 format' %
                             (t))
        return t
    else:
        return t.isoformat()