flex actionScript 시간 처리와 추가된 날짜 반환

1645 단어 actionScript시간

public class Util
 {
 public function Util()
 {
 }
 /**
  *  , date
  * @param datepart  
  * @param number  
  * @param date  date 
  * @return  date
  * yxy
  */
 public function dateAdd(datepart:String = "", number:Number = 0, date:Date = null):Date {
  if (date == null) {
  /* Default to current date. */
  date = new Date();
  }
  var returnDate:Date = new Date(date.time);;
  switch (datepart.toLowerCase()) {
  case "fullyear":
  case "month":
  case "date":
  case "hours":
  case "minutes":
  case "seconds":
  case "milliseconds":
   returnDate[datepart] += number;
   break;
  default:
   /* Unknown date part, do nothing. */
   break;
  }
  return returnDate;
 }
 /**
  *  date 
  * @param dataBegin  
  * @param dateEnd  
  * @return  
  *
  */
 public function dateDiff(dataBegin:Date,dateEnd:Date):Number{
  var diff:Number = (dateEnd.time-dataBegin.time)/new Number(24*60*60*1000);
  return diff;
 }
 /**
  *  date 
  * @param date1
  * @param date2
  * @return date1<date2 -1,date1=date2 0,date1>date2 1。
  *
  */
 public function dateCompare(date1:Date, date2:Date):int { 
  if (Number(date1) < Number(date2)) { 
  return -1 
  }
  if (Number(date1) == Number(date2)) { 
  return 0; 
  } 
  return 1; 
 }
 }

좋은 웹페이지 즐겨찾기