A Date-time query methods.
package engine
{
/**
* @file CDateTimeQuery.as
* @author Abhishek Kumar
*/
public class CDateTimeQuery
{
public function CDateTimeQuery()
{
}
public static function isExpired(yyyy:Number, mm:Number, dd:Number):Boolean
{
var today:Date = new Date();
var expiry:Date = new Date(yyyy, mm - 1, dd);
var decision:Boolean = (today > expiry) ? true : false;
return (decision);
}
public static function isValid(year:Number, month:Number, date:Number):Boolean
{
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
{
return ((date >= 1 && date <= 31)?true:false);
}
else if (month == 4 || month == 6 || month == 9 || month == 11)
{
return ((date >= 1 && date <= 30)?true:false);
}
else if (month == 2)
{
if (year%100 == 0)
{
return ((year % 400 == 0) ? ((date >= 1 && date <= 29)?true:false) : ((date >= 1 && date <= 28)?true:false));
}
else if (year%4 == 0)
{
return ((date >= 1 && date <= 29)?true:false);
}
else
{
return ((date >= 1 && date <= 28)?true:false);
}
}
return false;
}
}
}
Comments
Post a Comment