SoFunction
Updated on 2025-04-02

flex actionScript time processing adds back to the date after addition

flex actionScript time processing adds back to the date after addition

Updated: July 24, 2014 16:45:07 Submission: whsnow
This article mainly introduces the date after adding and adding. If you need it, please refer to it.
public class Util
 {
 public function Util()
 {
 }
 /**
   * Time processing class, add back the date after addition
   * @param datepart The time position to be added
   * @param number Added value
   * @param date The added date is not passed in the current time
   * @return Returns the date after addition
   * 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();;
  switch (()) {
  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;
 }
 /**
   * The time difference between two dates
   * @param dataBegin Start time
   * @param dateEnd time
   * @return Return the number of days of difference
   *
   */
 public function dateDiff(dataBegin:Date,dateEnd:Date):Number{
  var diff:Number = ()/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) &lt; Number(date2)) { 
  return -1 
  }
  if (Number(date1) == Number(date2)) { 
  return 0; 
  } 
  return 1; 
 }
 }
  • actionScript
  • time

Related Articles

  • Method for automatically expanding tree nodes after tree binding data in Flex

    Use the Tree component to automatically expand all tree nodes after binding data (the user does not need to click to expand the nodes by themselves, which will be much more convenient). Next, let’s introduce the specific implementation to you.
    2014-01-01
  • Validateall() method in flex implements multi-Item verification and the results are uniformly prompted

    In this article, we will introduce to you how to implement multi-Item verification in flex and the results are uniformly prompted. The details are as follows. Interested friends can refer to it.
    2013-09-09
  • Design ideas and codes for implementing dual-axis combination diagrams in Flex

    The combination chart is composed of a bar chart and a line chart. The data displayed on the bar chart is based on the vertical axis on the left, and the data of the line chart is based on the vertical axis on the right. For details, please read this article. I hope it will be helpful to everyone.
    2013-09-09
  • FLEX adds scrollbar implementation ideas and code to the page

    There are many ways to add scroll bars to the page. Use js to get the width and height of the browser window, modify the style according to the width and height of the browser window, and let the scroll bar appear. The specific implementation is as follows. Friends who need it can refer to it.
    2013-11-11
  • Implementation ideas and source code for mutual call of Flex parent-child windows

    This article mainly introduces the implementation ideas and source code of Flex parent-child windows. Friends who need it can refer to it
    2014-05-05
  • Flex AIR rebooting configuration files that need to be modified

    This section mainly introduces the configuration files that need to be modified for Flex AIR restart. Friends who need it can refer to it.
    2014-07-07
  • Flex calls a method of custom class in webservice

    How to call custom classes in webservice in flex, there is a good example below. Friends who don’t know can refer to it.
    2014-01-01
  • Flex DataGrid pseudo-merge cell ideas and codes

    This article mainly introduces the idea and code of Flex DataGrid pseudo-merge cells. Friends who need it can refer to it.
    2014-05-05
  • Example of Flex file reading error

    This article introduces the situation of Flex file reading errors in the form of an example. Friends who need it can refer to it
    2014-05-05
  • Flex tree with dotted lines to display the effect and replace the original icon

    Flex tree modifys the default icon and adds dotted lines to display the effect. I really can't stand the ugly little arrow + folder display method. The specific implementation is as follows. Friends who have this need can refer to it. I hope it will be helpful to my home.
    2013-08-08

Latest Comments