1. ホーム
  2. Web プログラミング
  3. フレックス

Flex 月の第1週を取得する 小 例

2022-01-19 06:24:44
<pre name="code" class="html">private function calcWeekTotal(showDate:Date):Array{ 
        showDate = DateFormatter.parseDateString("2013-04-01"); 
        //Get the date of the month 1 good 
        var oneDate:Date = new Date(showDate.fullYear,showDate.month,1); 
        // the date of the first Monday of the month 
        var oneWeekDate:int = 7 - oneDate.day + 2; 
        //the total number of days in the month 
        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); 
        // the current date is in the week of the month 
        var currentWeek:int = new int((showDate.date - oneWeekDate)/7) + 1; 
        if(currentWeek == 0){ 
          // last week of last month 
        } 
         
        var arr:Array = new Array(); 
        arr[0] = totalWeek; 
        arr[1] = currentWeek; 
        return arr; 
      }</pre><br> 
<br> 
<pre></pre>