计算今天是今年的第几周

算法:

/**
			 * 计算今天是今年的第几周
			 * @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");
			}


没有更多推荐了,返回首页