flex actionScript时间处理相加返回相加后的date(flex shrink)新鲜出炉

随心笔谈1年前发布 编辑
149 0


public class Util
{
public function Util()
{
}

public function dateAdd(datepart:String=””, number:Number=0, date:Date=null):Date {
if (date==null) {

date=new Date();
}
var returnDate:Date=new Date(date.time);;
switch (datepart.toLowerCase()) {
case “fullyear”:
case “month”:
case “date”:
case “hours”:
case “minutes”:
case “seconds”:
case “milliseconds”:
returnDate[datepart] +=number;
break;
default:

break;
}
return returnDate;
}

public function dateDiff(dataBegin:Date,dateEnd:Date):Number{
var diff:Number=(dateEnd.time-dataBegin.time)/new Number(24*60*60*1000);
return diff;
}

public function dateCompare(date1:Date, date2:Date):int {
if (Number(date1) < Number(date2)) {
return -1
}
if (Number(date1)==Number(date2)) {
return 0;
}
return 1;
}
}

© 版权声明

相关文章