I tried using the Amarghosh function, but I had problems with the UTC values. And from the first days of the year.
So I changed the setting of jan1 (depending on Sunday) and the calculation for the last week
Here is the function I'm using based on Amarghosh one:
public static function getWeek(date:Date):String { var days:Array = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; var year:Number = date.fullYear; var isLeap:Boolean = (year % 4 == 0) && (year % 100 != 0) || (year % 100 == 0) && (year % 400 == 0); if(isLeap) days[1]++; var d:Number = 0; for(var i:int = 0; i < (date.month); i++){ d += days[i]; } d += date.date; var temp:Date = new Date(year, 0, 1); var jan1:Number = temp.day; if(jan1 == 0)
Chris source share