算法:
/** * 计算今天是今年的第几周 * @author wangfeng * */ private function weekOfYear(yyyy:Number,mm:Number,dd:Number):Number { var myDate:Date = new Date(yyyy,mm-1,dd); var startDate:Date = new Date(yyyy,0,1); var diff:Number = myDate.valueOf()-startDate.valueOf(); var d:Number = Math.round(diff/86400000); return Math.ceil((d + ((startDate.getDay() + 1) - 1)) / 7); }
调用:
protected function weekCbb_initializeHandler(event:FlexEvent):void { weekCbb.textInput.editable = false; weekCbb.selectedIndex = (weekOfYear(new Date().getFullYear(),new Date().getMonth()+1,new Date().getDate()))-1; Alert.show("a"); }
作者:howlaa 发表于2013-3-29 11:59:45 原文链接
阅读:29 评论:0 查看评论