|
-
 Originally Posted by Michael REMY
another way :
Code:
public function WeekNumber(adate:Date):int{
//
// 1 - CALC JULIAN DATE NUMBER (note: nothing to do with the Julian calendar)
//
var wfullyear:int = adate.getFullYear();
var wmonth:int = adate.getMonth() + 1;
var wdate:int = adate.getDate();
//
var wa:int = Math.floor((14 - wmonth) / 12);
var wy:int = wfullyear + 4800 - wa;
var wm:int = wmonth + 12 * wa - 3;
//
// wJDN is the Julian Day Number
//
var wJDN:int = wdate + Math.floor(((153 * wm) + 2) / 5) + wy * 365
+ Math.floor(wy / 4)
- Math.floor(wy / 100)
+ Math.floor(wy / 400) - 32045;
//
// 2 - CALC WEEK NB
//
var d4:int = (((wJDN + 31741 - (wJDN % 7)) % 146097) % 36524) % 1461;
var L:int = Math.floor(d4 / 1460);
var d1:int = ((d4 - L) % 365) + L;
var wweekNb:int = Math.floor(d1 / 7) + 1;
return wweekNb;
};
very useful! thanks...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|