[ActionScript 3.0] AS3 获取某年某月的天数(Get number of days in a month)

function getNumberOfDays($year:int, $month:int):int
{
    var month:Date = new Date($year, $month + 1, 0);
    return month.date;
} 
 
//jan
trace(getNumberOfDays(2010, 0));  // traces 31
 
//feb
trace(getNumberOfDays(2010, 1)); // traces 28
 
//dec
trace(getNumberOfDays(2010, 11)); // traces 31

 

posted on 2016-02-19 12:58  晏过留痕  阅读(411)  评论(0编辑  收藏  举报