Packageorg.servebox.commons.utils
Classpublic class DateUtils

DateUtils is a helper class with a lot of static methods to handle dates.



Public Methods
 MethodDefined by
  
dateAdd(date:Date, mask:String, addValue:int):Date
[static] Adds given values to a date, using a mask.
DateUtils
  
dateAddOpenDatesOnly(date:Date, daysToAdd:int):Date
[static] Adds days to a given date, including only open dates.
DateUtils
  
dateComparator(obj1:Date, obj2:Date):Number
[static] Dates comparator function.
DateUtils
  
dateCopy(date:Date):Date
[static] Creates a fresh new clone of the passed date.
DateUtils
  
dateDiff(date1:Date, date2:Date, mask:String):Number
[static] Returns the difference between to dates, with the parameter mask as the unit.
DateUtils
  
[static] Returns the current date, with hh:mm:ss-ms set to 00:00:00-000.
DateUtils
  
getLastDayInMonth(fullYear:int, month:int):int
[static] Returns the last day for a given month and year.
DateUtils
  
getMidnightDateCopy(date:Date):Date
[static] Returns the copy of a date, with the time set to 00:00:00-000.
DateUtils
  
getSeparatorsOff(value:String):String
[static] Used to return a date typed in without any separators
DateUtils
  
isOpenDate(date:Date):Boolean
[static] Checks if a date is an open date (excluding saturday/sunday).
DateUtils
  
setRange(beginDate:Date, endDate:Date):Object
[static] Sets the selectable date range for a date component
DateUtils
  
validateInterval(beginDate:Date, endDate:Date):Boolean
[static] Use this fucntion to validate a property using two dates
DateUtils
  
validateIntervalInRange(beginDate:Date, endDate:Date, range:Array):Boolean
[static] This function is used to validate an interval in a specified date range
DateUtils
Method detail
dateAdd()method
public static function dateAdd(date:Date, mask:String, addValue:int):Date

Adds given values to a date, using a mask. The mask parameter can take the following values :
- d : Days.
- m : Months.
- y : Years.

Parameters
date:Date — The date to add value to.
 
mask:String — The mask to apply on addition.
 
addValue:int — The value to add. Can be negative.

Returns
Date — The new date.
dateAddOpenDatesOnly()method 
public static function dateAddOpenDatesOnly(date:Date, daysToAdd:int):Date

Adds days to a given date, including only open dates.

Parameters
date:Date — The date.
 
daysToAdd:int — The number of days to add. Can be negative.

Returns
Date — The new date.
dateComparator()method 
public static function dateComparator(obj1:Date, obj2:Date):Number

Dates comparator function.

Parameters
obj1:Date
 
obj2:Date

Returns
Number — a negative value if obj1 < obj2, zero is obj1 == obj2, a positive value is obj1 > obj2.
dateCopy()method 
public static function dateCopy(date:Date):Date

Creates a fresh new clone of the passed date.

Parameters
date:Date — The date to copy.

Returns
Date — A new Date, clone of an existing one.
dateDiff()method 
public static function dateDiff(date1:Date, date2:Date, mask:String):Number

Returns the difference between to dates, with the parameter mask as the unit. The mask parameter can take the following values :
- d : Days.
- m : Months.
- y : Years.
The method do not consider hours, minutes, seconds and milliseconds.

Parameters
date1:Date — The first operand.
 
date2:Date — The second operand.
 
mask:String — The unit to use.

Returns
Number — The difference ( date1 - date2).
getCurrentDate()method 
public static function getCurrentDate():Date

Returns the current date, with hh:mm:ss-ms set to 00:00:00-000.

Returns
Date — The current date.
getLastDayInMonth()method 
public static function getLastDayInMonth(fullYear:int, month:int):int

Returns the last day for a given month and year.

Parameters
fullYear:int — The year.
 
month:int — The month. (0-11)

Returns
int — The last day in month.
getMidnightDateCopy()method 
public static function getMidnightDateCopy(date:Date):Date

Returns the copy of a date, with the time set to 00:00:00-000.

Parameters
date:Date — The date to copy.

Returns
Date — The new date.
getSeparatorsOff()method 
public static function getSeparatorsOff(value:String):String

Used to return a date typed in without any separators

Parameters
value:String

Returns
String
isOpenDate()method 
public static function isOpenDate(date:Date):Boolean

Checks if a date is an open date (excluding saturday/sunday).

Parameters
date:Date — The date to check.

Returns
Boolean — A boolean indicating if the given date is an open one.
setRange()method 
public static function setRange(beginDate:Date, endDate:Date):Object

Sets the selectable date range for a date component

Parameters
beginDate:Date
 
endDate:Date

Returns
Object
validateInterval()method 
public static function validateInterval(beginDate:Date, endDate:Date):Boolean

Use this fucntion to validate a property using two dates

Parameters
beginDate:Date
 
endDate:Date

Returns
Boolean
validateIntervalInRange()method 
public static function validateIntervalInRange(beginDate:Date, endDate:Date, range:Array):Boolean

This function is used to validate an interval in a specified date range

Parameters
beginDate:Date
 
endDate:Date
 
range:Array

Returns
Boolean