January 3, 2012 - No Comments!

Code Snippet – Get Day in Year

Small code snippet that calculates the number of the selected day in the overall year (e.g. 1st Feb is the 32nd day of the year).

function getDayInYear(day:int,month:int,year:int):int
{
var day:int = day;
var month:int = month;
var year:int = year;
var dias:Array = [31,28,31,30,31,30,31,31,30,31,30];
if(year%4 == 0 && month > 1)
day++;
for(var i:int = 0;i < month;i++) day+=dias[i]; return day; }

Published by: nick in AS3, Code Sample, Flash, Flex

Leave a Reply