Packageflare.util
Classpublic class Dates

Utility methods for working with Date instances.



Public Methods
 MethodDefined by
  
Constructor, throws an error if called, as this is an abstract class.
Dates
  
addDays(d:Date, x:int):Date
[static] Adds days to a date instance.
Dates
  
addHours(d:Date, x:int):Date
[static] Adds hours to a date instance.
Dates
  
addMinutes(d:Date, x:int):Date
[static] Adds minutes to a date instance.
Dates
  
addMonths(d:Date, x:int):Date
[static] Adds months to a date instance.
Dates
  
addSeconds(d:Date, x:int):Date
[static] Adds seconds to a date instance.
Dates
  
addYears(d:Date, x:int):Date
[static] Adds years to a date instance.
Dates
  
roundTime(t:Date, span:int, roundUp:Boolean = false):Date
[static] Rounds a date according to a particular time span.
Dates
  
timeSpan(t:Date, s:Date):int
[static] Given two dates, returns a measure of the time span between them.
Dates
  
timeStep(span:int):Number
[static] Returns the number of milliseconds needed to step one time step forward according to the given time span measure.
Dates
  
toUTC(d:Date):Date
[static] Given a date, returns a date instance of the same time in Univeral Coordinated Time (UTC).
Dates
Public Constants
 ConstantDefined by
  DAYS : int = -2
[static] Constant indicating a time span on the order of days.
Dates
  HOURS : int = -3
[static] Constant indicating a time span on the order of hours.
Dates
  MILLISECONDS : int = -6
[static] Constant indicating a time span on the order of milliseconds.
Dates
  MINUTES : int = -4
[static] Constant indicating a time span on the order of minutes.
Dates
  MONTHS : int = -1
[static] Constant indicating a time span on the order of months.
Dates
  MS_DAY : Number = 86400000
[static] Number of milliseconds in a day.
Dates
  MS_HOUR : Number = 3600000
[static] Number of milliseconds in an hours.
Dates
  MS_MIN : Number = 60000
[static] Number of milliseconds in a minute.
Dates
  SECONDS : int = -5
[static] Constant indicating a time span on the order of seconds.
Dates
  WEEKS : int = -10
[static] Constant indicating a time span on the order of weeks.
Dates
  YEARS : int = 0
[static] Constant indicating a time span of one or more years.
Dates
Constructor detail
Dates()constructor
public function Dates()

Constructor, throws an error if called, as this is an abstract class.

Method detail
addDays()method
public static function addDays(d:Date, x:int):Date

Adds days to a date instance.

Parameters
d:Date — the date
 
x:int — the number of days to add (can be negative to subtract)

Returns
Date — a new Date representing the new date and time
addHours()method 
public static function addHours(d:Date, x:int):Date

Adds hours to a date instance.

Parameters
d:Date — the date
 
x:int — the number of hours to add (can be negative to subtract)

Returns
Date — a new Date representing the new date and time
addMinutes()method 
public static function addMinutes(d:Date, x:int):Date

Adds minutes to a date instance.

Parameters
d:Date — the date
 
x:int — the number of minutes to add (can be negative to subtract)

Returns
Date — a new Date representing the new date and time
addMonths()method 
public static function addMonths(d:Date, x:int):Date

Adds months to a date instance.

Parameters
d:Date — the date
 
x:int — the number of months to add (can be negative to subtract)

Returns
Date — a new Date representing the new date and time
addSeconds()method 
public static function addSeconds(d:Date, x:int):Date

Adds seconds to a date instance.

Parameters
d:Date — the date
 
x:int — the number of seconds to add (can be negative to subtract)

Returns
Date — a new Date representing the new date and time
addYears()method 
public static function addYears(d:Date, x:int):Date

Adds years to a date instance.

Parameters
d:Date — the date
 
x:int — the number of years to add (can be negative to subtract)

Returns
Date — a new Date representing the new date and time
roundTime()method 
public static function roundTime(t:Date, span:int, roundUp:Boolean = false):Date

Rounds a date according to a particular time span. Date values are rounded to the minimum date/time value of the time span (the first day in a year, month, or week, or the beginning of a day, hours, minute, second, etc).

Parameters
t:Date — the date to round
 
span:int — the time span to which the date should be rounded, legal values are YEARS, MONTHS, WEEKS, DAYS, HOURS, MINUTES, SECONDS, or MILLISECONDS
 
roundUp:Boolean (default = false) — if true, the date will be rounded up to nearest value, otherwise it will be rounded down (the default)

Returns
Date — a new Date representing the rounded date and time.
timeSpan()method 
public static function timeSpan(t:Date, s:Date):int

Given two dates, returns a measure of the time span between them.

Parameters
t:Date — the first date to compare
 
s:Date — the second date to compare

Returns
int — an integer value indicating the time span between dates. If the return value is positive, it represents the number of years between dates. Otherwise, the return value is one of MONTHS, DAYS, HOURS, MINUTES, SECONDS, or MILLISECONDS.
timeStep()method 
public static function timeStep(span:int):Number

Returns the number of milliseconds needed to step one time step forward according to the given time span measure.

Parameters
span:int — the time span for which to return a time step value. Legal values are any positive numbers (representing years) or DAYS, HOURS, MINUTES, SECONDS, and MILLISECONDS. Note that the MONTHS time span is not supported and will result in a zero return value.

Returns
Number — the number of milliseconds needed to more one time step ahead according to the input time span. For years (positive integer input), this step is the nearest power of ten less than the input value.
toUTC()method 
public static function toUTC(d:Date):Date

Given a date, returns a date instance of the same time in Univeral Coordinated Time (UTC).

Parameters
d:Date — the date to convert

Returns
Date
Constant detail
DAYSconstant
public static const DAYS:int = -2

Constant indicating a time span on the order of days.

HOURSconstant 
public static const HOURS:int = -3

Constant indicating a time span on the order of hours.

MILLISECONDSconstant 
public static const MILLISECONDS:int = -6

Constant indicating a time span on the order of milliseconds.

MINUTESconstant 
public static const MINUTES:int = -4

Constant indicating a time span on the order of minutes.

MONTHSconstant 
public static const MONTHS:int = -1

Constant indicating a time span on the order of months.

MS_DAYconstant 
public static const MS_DAY:Number = 86400000

Number of milliseconds in a day.

MS_HOURconstant 
public static const MS_HOUR:Number = 3600000

Number of milliseconds in an hours.

MS_MINconstant 
public static const MS_MIN:Number = 60000

Number of milliseconds in a minute.

SECONDSconstant 
public static const SECONDS:int = -5

Constant indicating a time span on the order of seconds.

WEEKSconstant 
public static const WEEKS:int = -10

Constant indicating a time span on the order of weeks.

YEARSconstant 
public static const YEARS:int = 0

Constant indicating a time span of one or more years.