欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Flex 获取每月第几周小例子

程序员文章站 2022-06-28 14:07:00
private function calcweektotal(showdate:date):...
<pre name="code" class="html">private function calcweektotal(showdate:date):array{ 
        showdate = dateformatter.parsedatestring("2013-04-01"); 
        //获取本月1好的日期 
        var onedate:date = new date(showdate.fullyear,showdate.month,1); 
        //本月第一周星期一的日期 
        var oneweekdate:int = 7 - onedate.day + 2; 
        //本月共几天 
        var totalday :int= new date(showdate.fullyear,showdate.month,0).date; 
        var totalweek:int = (totalday - oneweekdate + 1) % 7 == 0 ? 
          (totalday - oneweekdate + 1) /7:(totalday - oneweekdate + 1) /7 + 1; 
        trace(totalweek); 
        //当前日期在本月第几周 
        var currentweek:int = new int((showdate.date - oneweekdate)/7) + 1; 
        if(currentweek == 0){ 
          //上个月最后一周 
        } 
         
        var arr:array = new array(); 
        arr[0] = totalweek; 
        arr[1] = currentweek; 
        return arr; 
      }</pre><br> 
<br> 
<pre></pre> 
相关标签: 每月 第几周