Packagecom.yahoo.astra.utils
Classpublic class DateUtil

A collection of utility functions for the manipulation and inspection of date and time values.

See also

Date


Public Properties
 PropertyDefined by
  daysInMonths : Array
[static] The number of days appearing in each month.
DateUtil
  months : Array
[static] The names of months in English.
DateUtil
Public Methods
 MethodDefined by
  
countDays(start:Date, end:Date):Number
[static] Determines the number of days between the start value and the end value.
DateUtil
  
getDateDifferenceByTimeUnit(minDate:Date, maxDate:Date, timeUnit:String):Number
[static]
DateUtil
  
getHoursIn12HourFormat(value:Date):Number
[static] Determines the hours value in the range 1 - 12 for the AM/PM time format.
DateUtil
  
getMonthName(index:int):String
[static] Gets the English name of the month specified by index.
DateUtil
  
getShortMonthName(index:int):String
[static] Gets the abbreviated month name specified by index.
DateUtil
  
isLeapYear(year:int):Boolean
[static] Determines if the input year is a leap year (with 366 days, rather than 365).
DateUtil
  
roundDown(dateToRound:Date, timeUnit:String = "day"):Date
[static] Rounds a Date value down to the nearest value on the specified time unit.
DateUtil
  
roundUp(dateToRound:Date, timeUnit:String = "day"):Date
[static] Rounds a Date value up to the nearest value on the specified time unit.
DateUtil
  
timeCodeToUTC(timecode:String):String
[static] Converts a time code to UTC.
DateUtil
Public Constants
 ConstantDefined by
  DAYS_IN_APRIL : int = 30
[static] The number of days in April.
DateUtil
  DAYS_IN_AUGUST : int = 31
[static] The number of days in August.
DateUtil
  DAYS_IN_DECEMBER : int = 31
[static] The number of days in December.
DateUtil
  DAYS_IN_FEBRUARY : int = 28
[static] The number of days in February on a standard year.
DateUtil
  DAYS_IN_FEBRUARY_LEAP_YEAR : int = 29
[static] The number of days in February on a leap year.
DateUtil
  DAYS_IN_JANUARY : int = 31
[static] The number of days in January.
DateUtil
  DAYS_IN_JULY : int = 31
[static] The number of days in July.
DateUtil
  DAYS_IN_JUNE : int = 30
[static] The number of days in June.
DateUtil
  DAYS_IN_LEAP_YEAR : int = 366
[static] The number of days in a leap year.
DateUtil
  DAYS_IN_MARCH : int = 31
[static] The number of days in March.
DateUtil
  DAYS_IN_MAY : int = 31
[static] The number of days in May.
DateUtil
  DAYS_IN_NOVEMBER : int = 30
[static] The number of days in November.
DateUtil
  DAYS_IN_OCTOBER : int = 31
[static] The number of days in October.
DateUtil
  DAYS_IN_SEPTEMBER : int = 30
[static] The number of days in September.
DateUtil
  DAYS_IN_YEAR : int = 365
[static] The number of days in a standard year.
DateUtil
Property detail
daysInMonthsproperty
public static var daysInMonths:Array

The number of days appearing in each month. May be used for easy index lookups. The stored value for February corresponds to a standard year--not a leap year.

monthsproperty 
public static var months:Array

The names of months in English. The index in the array corresponds to the value of the month in a date object.

Method detail
countDays()method
public static function countDays(start:Date, end:Date):Number

Determines the number of days between the start value and the end value. The result may contain a fractional part, so cast it to int if a whole number is desired.

Parameters
start:Date — start the starting date of the range
 
end:Date — end the ending date of the range

Returns
Number — the number of dats between start and end
getDateDifferenceByTimeUnit()method 
public static function getDateDifferenceByTimeUnit(minDate:Date, maxDate:Date, timeUnit:String):NumberParameters
minDate:Date
 
maxDate:Date
 
timeUnit:String

Returns
Number
getHoursIn12HourFormat()method 
public static function getHoursIn12HourFormat(value:Date):Number

Determines the hours value in the range 1 - 12 for the AM/PM time format.

Parameters
value:Date — the input Date value

Returns
Number — the calculated hours value
getMonthName()method 
public static function getMonthName(index:int):String

Gets the English name of the month specified by index. This is the month value as stored in a Date object.

Parameters
index:int — index the numeric value of the month

Returns
String — the string name of the month in English
getShortMonthName()method 
public static function getShortMonthName(index:int):String

Gets the abbreviated month name specified by index. This is the month value as stored in a Date object.

Parameters
index:int — index the numeric value of the month

Returns
String — the short string name of the month in English
isLeapYear()method 
public static function isLeapYear(year:int):Boolean

Determines if the input year is a leap year (with 366 days, rather than 365).

Parameters
year:int — year the year value as stored in a Date object.

Returns
Boolean — true if the year input is a leap year
roundDown()method 
public static function roundDown(dateToRound:Date, timeUnit:String = "day"):Date

Rounds a Date value down to the nearest value on the specified time unit.

Parameters
dateToRound:Date
 
timeUnit:String (default = "day")

Returns
Date

See also

roundUp()method 
public static function roundUp(dateToRound:Date, timeUnit:String = "day"):Date

Rounds a Date value up to the nearest value on the specified time unit.

Parameters
dateToRound:Date
 
timeUnit:String (default = "day")

Returns
Date

See also

timeCodeToUTC()method 
public static function timeCodeToUTC(timecode:String):String

Converts a time code to UTC.

Parameters
timecode:String — the input timecode

Returns
String — the UTC value
Constant detail
DAYS_IN_APRILconstant
public static const DAYS_IN_APRIL:int = 30

The number of days in April.

DAYS_IN_AUGUSTconstant 
public static const DAYS_IN_AUGUST:int = 31

The number of days in August.

DAYS_IN_DECEMBERconstant 
public static const DAYS_IN_DECEMBER:int = 31

The number of days in December.

DAYS_IN_FEBRUARYconstant 
public static const DAYS_IN_FEBRUARY:int = 28

The number of days in February on a standard year.

DAYS_IN_FEBRUARY_LEAP_YEARconstant 
public static const DAYS_IN_FEBRUARY_LEAP_YEAR:int = 29

The number of days in February on a leap year.

DAYS_IN_JANUARYconstant 
public static const DAYS_IN_JANUARY:int = 31

The number of days in January.

DAYS_IN_JULYconstant 
public static const DAYS_IN_JULY:int = 31

The number of days in July.

DAYS_IN_JUNEconstant 
public static const DAYS_IN_JUNE:int = 30

The number of days in June.

DAYS_IN_LEAP_YEARconstant 
public static const DAYS_IN_LEAP_YEAR:int = 366

The number of days in a leap year.

DAYS_IN_MARCHconstant 
public static const DAYS_IN_MARCH:int = 31

The number of days in March.

DAYS_IN_MAYconstant 
public static const DAYS_IN_MAY:int = 31

The number of days in May.

DAYS_IN_NOVEMBERconstant 
public static const DAYS_IN_NOVEMBER:int = 30

The number of days in November.

DAYS_IN_OCTOBERconstant 
public static const DAYS_IN_OCTOBER:int = 31

The number of days in October.

DAYS_IN_SEPTEMBERconstant 
public static const DAYS_IN_SEPTEMBER:int = 30

The number of days in September.

DAYS_IN_YEARconstant 
public static const DAYS_IN_YEAR:int = 365

The number of days in a standard year.