计算指定日期是当月第几周:
private function weekOfMonth(yyyy:Number, mm:Number, dd:Number):Number
{
var myDate=new Date(yyyy, mm - 1, dd);
var diff=myDate.getDate() - 1;
myDate.setDate(1);
var dateWeek=7 - myDate.getDay();
if (diff > dateWeek)
{
diff-=dateWeek;
var dateMod=diff % 7;
if (dateMod > 0)
{
return (diff - dateMod) / 7 + 2;
}
else
{
return diff / 7 + 1;
}
}
else
{
return 1;
}
}
计算指定日期是当年第几周:
private function weekOfYear(yyyy:Number,mm:Number,dd:Number):Number{
var myDate =new Date(yyyy, mm - 1, dd);
var startDate = new Date(yyyy,0,1);
var diff = myDate.valueOf() - startDate.valueOf();
var d = Math.round(diff/86400000);
return Math.ceil((d + ((startDate.getDay() + 1) - 1)) / 7);
}
运行结果就不贴图了,有需要的朋友可以自己试试。。。。。。
标签:FLEX,return,几周,myDate,Number,yyyy,当月,var,diff From: https://blog.51cto.com/u_16129500/6354897