悠然哈哈哈

导航

实现日期比较

public function next(event:MouseEvent):void{
    var date:Date= DateFormatter.parseDateString(showDate);
    date.setDate(date.date+1);
    showDate=AFCDate.parseCurrentCalendar(date).substring(0,10);
    timeLabel.text=showDate;
    //判断(下一天)时间不能大于结束时间
    resetButton();
    if(parentUI.scheduleMap.hasKey(showDate)){
     documentDG.dataProvider=parentUI.scheduleMap.itemFor(showDate) as ArrayCollection;
    }
   }
   public function preDay(event:MouseEvent):void{
    var date:Date= DateFormatter.parseDateString(showDate);
    date.setDate(date.date-1);
    showDate=AFCDate.parseCurrentCalendar(date).substring(0,10);
    timeLabel.text=showDate;
    //判断(上一天)时间不能小于开始时间
    resetButton();
    if(parentUI.scheduleMap.hasKey(showDate)){
     documentDG.dataProvider=parentUI.scheduleMap.itemFor(showDate) as ArrayCollection;
    }
   }
   private function resetButton():void{
    var showDay:String=showDate.toString();
    var startDay:String=parentUI.startDate.value.toString().substring(0,10);
    var endDay:String=parentUI.endDate.value.toString().substring(0,10);
    var myPattern:RegExp=/-|:| /g;
    showDay=showDay.replace(myPattern,'');
    startDay=startDay.replace(myPattern,'');
    endDay=endDay.replace(myPattern, '');
    if(Number(showDay)>=Number(endDay)){
     nextButton.enabled=false;
    }else{
     nextButton.enabled=true;
    }
    if(Number(showDay)<=Number(startDay)){
     preDayButton.enabled=false;
    }else{
     preDayButton.enabled=true;
    }
   }

posted on 2013-09-18 18:39  悠然886  阅读(209)  评论(0编辑  收藏  举报