function validateDate(getFn){
if(getFn){ this.converter = dateStringToInt; return compareConvertedFEW; }
var date = (new MyDate()).setFromString(this.get(), this.partition);
var mssg = date.checkIsValid();
if(mssg != ""){
return this.setMessage(mssg);
}else{
this.set(date.getAsString(this.monthFormat, this.yearFormat));
}

var overMax = this.compareNullable(this.maximum, ">");
if(this.compareNullable(this.minimum, "<"))
return this.setMessage("The date must not be before " + dateIntToString(getValueFor(this.minimum, dateStringToInt), this.monthFormat, this.yearFormat) + ".");
if(overMax)
return this.setMessage("The date must not be after " + dateIntToString(getValueFor(this.maximum, dateStringToInt), this.monthFormat, this.yearFormat) + ".");
return true;
}
function dateStringToInt(value){
return (new MyDate()).setFromString(value).getAsInt();
}
function dateIntToString(value, monthFormat, yearFormat){
return (new MyDate()).setFromInt(value).getAsString(monthFormat, yearFormat);
}

function validateTime(getFn){
if(getFn){ this.converter = timeStringToInt; return compareConvertedFEW; }
var time = (new MyTime()).setFromString(this.get());
if(time.hour != null)
this.set(time.getAsString(this.seconds == true, this.military == true));
var mssg = time.checkIsValid();
if(mssg != "") return this.setMessage(mssg);

var minAsInt = getValueFor(this.minimum, timeStringToInt);
var maxAsInt = getValueFor(this.maximum, timeStringToInt);
var minAsStr = minAsInt != null ? timeIntToString(minAsInt, this.seconds == true, this.military == true) : "";
var maxAsStr = maxAsInt != null ? timeIntToString(maxAsInt, this.seconds == true, this.military == true) : "";
var isAfterMax = this.compareNullable(this.maximum, ">");
var isBeforeMin = this.compareNullable(this.minimum, "<");
if(maxAsInt == null || minAsInt == null){
if(isBeforeMin)
return this.setMessage("The time must not be before " + minAsStr + ".");
if(isAfterMax)
return this.setMessage("The time must not be after " + maxAsStr + ".");
return true;
}
if(minAsInt > maxAsInt){
if(!isAfterMax || !isBeforeMin)
return true;
}else{
if(!isAfterMax && !isBeforeMin)
return true;
}
return this.setMessage("The time must be between " + minAsStr + " and " + maxAsStr + ".");
}
function timeStringToInt(value){
return (new MyTime()).setFromString(value).getAsInt();
}
function timeIntToString(value, showSeconds, military){
return (new MyTime()).setFromInt(value).getAsString(showSeconds, military);
}

function validateMonthYear(getFn){
if(getFn){ this.converter = monthYearStringToInt; return compareConvertedFEW; }
if(this.minimum == "creditCardExpire"){
var today = (new MyDate()).setFromDate(currentDateTime());
this.minimum = today.month + "/" + today.year;
}
var month = new MonthYear(this.get(), this.partition);
var mssg = month.checkIsValid();
if(mssg != ""){
if(mssg == "Please enter a valid date.") mssg = "Please enter a valid month and year.";
return this.setMessage(mssg);
}else{
this.set(month.getAsString(this.monthFormat, this.yearFormat));
}

var overMax = this.compareNullable(this.maximum, ">");
if(this.compareNullable(this.minimum, "<"))
return this.setMessage("The month and year must not be before " + monthYearIntToString(getValueFor(this.minimum, monthYearStringToInt), this.monthFormat, this.yearFormat) + ".");
if(overMax)
return this.setMessage("The month and year date must not be after " + monthYearIntToString(getValueFor(this.maximum, monthYearStringToInt), this.monthFormat, this.yearFormat) + ".");
return true;
}
function monthYearStringToInt(value){
return (new MonthYear(value)).getAsInt();
}
function monthYearIntToString(value, monthFormat, yearFormat){
return (new MonthYear()).setFromInt(value).getAsString(monthFormat, yearFormat);
}

function validateTimeList() {
var newTimes = "", time, token, mssg;
var tokenizer = new Tokenizer(this.get(), ",; ");
for (token = tokenizer.nextToken(); token != null; token = tokenizer.nextToken()) {
if (token != "") {
time = (new MyTime()).setFromString(token);
mssg = time.checkIsValid();
if (mssg != "") return this.setMessage(mssg + " (" + token + ")");
token = time.getAsString(this.seconds == true, this.military == true);
if (newTimes.length > 0) newTimes += ", ";
newTimes += token;
}
}
this.set(newTimes);
if (newTimes == "") return this.setMessage("This is a required field.");
return true;
}


function MonthYear(str, partition){
this.checkIsValid = checkIsValidMD;
this.setFromString = setFromStringMY;
this.setFromInt = setFromIntMD;
this.setFromDate = setFromDateMD;
this.getAsString = getAsStringMY;
this.getAsInt = getAsIntMD;
this.getAsDate = getAsDateMD;
this.getMonthName = getMonthNameMD;
this.getDaysInMonth = getDaysInMonthMD;
this.month = 0;
this.year = 0;
this.day = 1;
if(str != null) this.setFromString(str, partition);
}
function setFromStringMY(str, partition){
if(str == TIMESTAMP) {
var date = currentDateTime();
this.year = date.getYear();
if(this.year < 1000) this.year += 1900;
this.month = date.getMonth() + 1;
return this;
}
var tokens = parseDateTime(str, dateSeparators);
if(tokens.length != 2){
tokens[0] = parseMonthName(str) + 1;
tokens[1] = (tokens[0] > 12) ? null : extract(str, NUMERIC);
if(tokens[1] == "") tokens[1] = currentYear();
}
if(tokens[0].length == 4){
var temp = tokens[0];
tokens[0] = tokens[1];
tokens[1] = temp;
}
if(tokens[0] == 0) return this;

this.month = parseInt(tokens[0], 10);
this.year = (tokens[1] == null) ? null : parseInt(tokens[1], 10);
if(this.year != null && this.year < 100){
if(partition == null) partition = (currentYear() + 50) % 100;
this.year = 2000 + ((this.year >= partition) ? this.year - 100 : this.year);
}
return this;
}
function getAsStringMY(monthFormat, yearFormat){
var out = "", yearSpacer = " ";
if(monthFormat == SHORT_MONTH){
out += this.getMonthName(true);
}else if(monthFormat >= LONG_MONTH){
out += this.getMonthName(false);
}else{
out += twoDigit(this.month);
yearSpacer = "/"
}
if(yearFormat == FULL_YEAR){
out += yearSpacer + this.year;
}else if(yearFormat != NO_YEAR){
out += yearSpacer + twoDigit(this.year % 100);
}
return out;
}
var _SR_;
if(_SR_ != null) _SR_.notify("validatedate.js");