Check if date is valid for specific month (and year for February). Month: 0 = Jan, 1 = Feb, etc
349701
function isValid(year, month, date) {
        if (date < 1) {
            return false;
        }

        if (month === 1 && date > 28) {
            return date === 29 && (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0);
        }

        if (month === 3 || month === 5 || month === 8 || month === 10) {
            return date < 31;
        }

        return true;
    }
15105
def _getFromDate(l, date):
    '''
    
    '''
    try:
        date = _toDate(date)
        i = _insertDateIndex(date, l) - 1
        if i == -1:
            return l[0]
        return l[i]
    except (ValueError, TypeError):
        # ValueError: date invalid / TypeError: date = None
        return l[0]
1103914
function(date) {    
            function format(number) {
                // Format integers to have at least two digits.
                return (number < 10) ? '0' + number : number;
            }
            return '"' + date.getFullYear() + '-' +
                    format(date.getMonth() + 1) + '-' +
                    format(date.getDate()) + 'T' +
                    format(date.getHours()) + ':' +
                    format(date.getMinutes()) + ':' +
                    format(date.getSeconds()) + '"';
        }
519944
function getDisplayDate(date) {
        var monthStrings = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

        date = new Date(date);

        var hours = date.getHours();
        if (hours < 10) {
            hours = "0" + hours.toString();
        }
        var mins = date.getMinutes();
        if (mins < 10) {
            mins = "0" + mins.toString();
        }

        return monthStrings[date.getMonth()] + " " + date.getDate() + ", " + date.getFullYear() +
            " - " + hours + ":" + mins + " " + (date.getUTCHours() < 12 ? "AM" : "PM");
    }
1126807
def month(self, month):
        
        if month is None:
            raise ValueError("Invalid value for `month`, must not be `None`")
        if month is not None and not re.search('^\\d{4}-\\d{2}$', month):
            raise ValueError("Invalid value for `month`, must be a follow pattern or equal to `/^\\d{4}-\\d{2}$/`")

        self._month = month
523945
def valid_date(x: str) -> bool:
    
    try:
        if x != dt.datetime.strptime(x, DATE_FORMAT).strftime(DATE_FORMAT):
            raise ValueError
        return True
    except ValueError:
        return False
1045865
public static function validateDate(string $date): bool
    {
        $date = Text::keepNumeric($date);
        $day = (int)substr($date, 0, 2);
        $month = (int)substr($date, 2, 2);
        if ($month < 0 || $month > 12) {
            return false;
        }
        // @formatter:off
        $months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
        // @formatter:on
        if ((int)substr($date, 4, 2) % 4 === 0) {
            $months[1] = 29;
        }

        return $day > 0 && $day <= $months[$month - 1];
    }
197079
def value_validate(self, value):
        
        if not isinstance(value, datetime.date):
            raise tldap.exceptions.ValidationError("is invalid date")
        # a datetime is also a date but they are not compatable
        if isinstance(value, datetime.datetime):
            raise tldap.exceptions.ValidationError("should be a date, not a datetime")
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)
334317
private static boolean isDateType(Cell cell, int formatIndex) {
		// yyyy-MM-dd----- 14
		// yyyy年m月d日---- 31
		// yyyy年m月------- 57
		// m月d日 ---------- 58
		// HH:mm----------- 20
		// h时mm分 -------- 32
		if (formatIndex == 14 || formatIndex == 31 || formatIndex == 57 || formatIndex == 58 || formatIndex == 20 || formatIndex == 32) {
			return true;
		}

		if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) {
			return true;
		}

		return false;
	}
984436
def legal_date(year, month, day):
    ''''''
    daysinmonth = month_length(year, month)

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

    return True
436774
def is_date(self):
        """"""
        dt = DATA_TYPES['date']
        if type(self.data) is dt['type'] and '-' in str(self.data) and str(self.data).count('-') == 2:
            # Separate year, month and day
            date_split = str(self.data).split('-')
            y, m, d = date_split[0], date_split[1], date_split[2]

            # Validate values
            valid_year, valid_months, valid_days = int(y) in YEARS, int(m) in MONTHS, int(d) in DAYS

            # Check that all validations are True
            if all(i is True for i in (valid_year, valid_months, valid_days)):
                self.type = 'date'.upper()
                self.len = None
                return True
989116
private static boolean checkDate(Calendar cal, int date, int month) {
		return cal.get(Calendar.DATE) == date && cal.get(Calendar.MONTH) == month;
	}
1005585
private void checkJodaGetMonth() {
        int COUNT = COUNT_VERY_FAST;
        DateTime dt = new DateTime(GJChronology.getInstance());
        for (int i = 0; i < AVERAGE; i++) {
            start("Joda", "getMonth");
            for (int j = 0; j < COUNT; j++) {
                int val = dt.getMonthOfYear();
                if (val == 0) {System.out.println("Anti optimise");}
            }
            end(COUNT);
        }
    }
1065781
function stringDate(value) {
    //  Empty string
    if (!value.length)
        return false;
    //  MM.DD.YYYY. - format
    //  valid separators -> . , / - \s
    if (value.search(/[.,/\\-]/g) > -1) {
        var date = value.split(/[.,/-\s]/g);
        var month = +date[0];
        var day = +date[1];
        var isValid = void 0;
        for (var _i = 0, months_2 = months_1.months; _i < months_2.length; _i++) {
            var _month = months_2[_i];
            (_month.ord >= month && _month.days >= day) ? isValid = true : isValid = false;
        }
        return isValid ? !isNaN(Date.parse(value)) : false;
    }
    //  YYYY-MM-DDTTT:HH:MM.SSSZ - format
    return !isNaN(Date.parse(value));
}
1223980
def _days_in_month(date):
    """"""
    if date.month == 12:
        reference = type(date)(date.year + 1, 1, 1)
    else:
        reference = type(date)(date.year, date.month + 1, 1)
    return (reference - timedelta(days=1)).day
553518
def _get_date(day=None, month=None, year=None):
    """"""

    now = datetime.date.today()
    if day is None:
        return now

    try:
        return datetime.date(
            day=int(day),
            month=int(month or now.month),
            year=int(year or now.year),
        )
    except ValueError as error:
        print("error: {0}".format(error), file=sys.stderr)