com.yahoo.astra.utils.DateUtil
Keywords: DateUtil,com.yahoo.astra.utils.DateUtil,DAYS_IN_APRIL,DAYS_IN_AUGUST,DAYS_IN_DECEMBER,DAYS_IN_FEBRUARY,DAYS_IN_FEBRUARY_LEAP_YEAR,DAYS_IN_JANUARY,DAYS_IN_JULY,DAYS_IN_JUNE,DAYS_IN_LEAP_YEAR,DAYS_IN_MARCH,DAYS_IN_MAY,DAYS_IN_NOVEMBER,DAYS_IN_OCTOBER,DAYS_IN_SEPTEMBER,DAYS_IN_YEAR,daysInMonths,months,countDays,getDateDifferenceByTimeUnit,getHoursIn12HourFormat,getMonthName,getShortMonthName,isLeapYear,roundDown,roundUp,timeCodeToUTC

YUI Flash Component Documentation | All Packages | All Classes | Index | Frames No Frames |
Class DateUtil

Package | com.yahoo.astra.utils
Class | public class DateUtil

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

See also

Date

Public Properties

| Property | Defined 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

| Method | Defined 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

| Constant | Defined 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

daysInMonths | property

`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.

months | property |

`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):Number`Parameters

| `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

com.yahoo.astra.utils.TimeUnit

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

com.yahoo.astra.utils.TimeUnit

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_APRIL | constant

`public static const DAYS_IN_APRIL:int = 30`

The number of days in April.

DAYS_IN_AUGUST | constant |

`public static const DAYS_IN_AUGUST:int = 31`

The number of days in August.

DAYS_IN_DECEMBER | constant |

`public static const DAYS_IN_DECEMBER:int = 31`

The number of days in December.

DAYS_IN_FEBRUARY | constant |

`public static const DAYS_IN_FEBRUARY:int = 28`

The number of days in February on a standard year.

DAYS_IN_FEBRUARY_LEAP_YEAR | constant |

`public static const DAYS_IN_FEBRUARY_LEAP_YEAR:int = 29`

The number of days in February on a leap year.

DAYS_IN_JANUARY | constant |

`public static const DAYS_IN_JANUARY:int = 31`

The number of days in January.

DAYS_IN_JULY | constant |

`public static const DAYS_IN_JULY:int = 31`

The number of days in July.

DAYS_IN_JUNE | constant |

`public static const DAYS_IN_JUNE:int = 30`

The number of days in June.

DAYS_IN_LEAP_YEAR | constant |

`public static const DAYS_IN_LEAP_YEAR:int = 366`

The number of days in a leap year.

DAYS_IN_MARCH | constant |

`public static const DAYS_IN_MARCH:int = 31`

The number of days in March.

DAYS_IN_MAY | constant |

`public static const DAYS_IN_MAY:int = 31`

The number of days in May.

DAYS_IN_NOVEMBER | constant |

`public static const DAYS_IN_NOVEMBER:int = 30`

The number of days in November.

DAYS_IN_OCTOBER | constant |

`public static const DAYS_IN_OCTOBER:int = 31`

The number of days in October.

DAYS_IN_SEPTEMBER | constant |

`public static const DAYS_IN_SEPTEMBER:int = 30`

The number of days in September.

DAYS_IN_YEAR | constant |

`public static const DAYS_IN_YEAR:int = 365`

The number of days in a standard year.