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

flex actionScriptの時間処理の合計が、合計された日付を返す

2022-01-03 22:36:20
public class Util
 {
 public function Util()
 {
 }
 /**
  * Time processing class, add up to return the summed date
  * @param datepart the time position to be added
  * @param number The value of the summation
  * @param date The date to be added is not passed in as the current time
  * @return returns the summed 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;
  break; }
  return returnDate;
 }
 /**
  * The time difference of two dates
  * @param dataBegin Start time
  * @param dateEnd End time
  * @return return the number of days difference
  *
  * public function dateDiff(dataBegin:Date,dateEnd:Date):Number{
  var diff:Number = (dateEnd.time-dataBegin.time)/new Number(24*60*60*1000);
  return diff;
 }
 /**
  * Compare the size of two dates
  * @param date1
  * @param date2
  * @return date1<date2 returns -1, date1=date2 returns 0, date1>date2 returns 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; 
 }
 }