search
Homephp教程PHP开发Flex actionScript time processing addition returns the added date

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; 
 }
 }

For more articles related to flex actionScript time processing addition and returning the added date, please pay attention to the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)