[AS3 SNIPPET] Format day, month and year to full date

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function formatFullDate(year:Number, month:Number, day:Number):String
{
    var days:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
    var months:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    var currentDate:Date = new Date(year, month - 1, day, 1, 1);
    var currentDay:String = days[currentDate.getDay()];
    var currentMonth:String = months[currentDate.getMonth()];
    var output:String = currentDay + " " + day + " " + currentMonth + ", " + year;
   
    return output;
}

var formattedDate:String = formatFullDate(2009, 7, 7);
trace(formattedDate); //traces Tuesday 7 July, 2009