Class com.sekati.utils.DateUtils

Description

Static function for handling dates from db and converting them into readable strings. Note that days & months are 0-indexed.

 Usage:
 var d = DateUtils.dateFromDB("2006-06-01 12:10:45");
 trace(DateUtils.days[d.getDay()] + ", " + DateUtils.months[d.getMonth()] + " " + d.getDate() + ", " + (d.getHours()%12) + ":" + DateUtils.padTime(d.getMinutes()) + ((d.getHours() > 12) ? "pm" :"am"));
 

Field Index

days, months, shortdays, shortmonths

Method Index

dateDiff(), dateFromDB(), getDay(), getHoursAmPm(), getMonth(), getShortDay(), getShortMonth(), getTotalDaysInMonth(), getTotalDaysInYear(), isValidAge(), isValidDate(), padTime()

Field Detail

months

static public months:Array [Read Only]
Gets 0 indexed array of months for use with Date.getMonth()

shortmonths

static public shortmonths:Array [Read Only]
Gets 0 indexed array of short months for use with Date.getMonth()

days

static public days:Array [Read Only]
Gets 0 indexed array of days for use with Date.getDay()

shortdays

static public shortdays:Array [Read Only]
Get 0 indexed array of days for use with Date.getDay();

Method Detail

getMonth

static public function getMonth(n:Number):String

Get the month name by month number.

Parameters

n(Number)

Return

String

 Usage:
 	trace(DateUtils.getMonth(0); // returns "January"
 

getShortMonth

static public function getShortMonth(n:Number):String

Get the short month name by month number.

Parameters

n(Number)

Return

String

 Usage:
 	trace(DateUtils.getShortMonth(0); // returns "Jan"
 

getDay

static public function getDay(n:Number):String

Get the day name by day number.

Parameters

n(Number)

Return

String

 Usage:
 	trace(DateUtils.getDay(0); // returns "Sunday"
 

getShortDay

static public function getShortDay(n:Number):String

Get the short day name by day number.

Parameters

n(Number)

Return

String

 Usage:
 	trace(DateUtils.getShortDay(0); // returns "Sun"
 

padTime

static public function padTime(n:Number):String

Pads hours, Minutes or Seconds with a leading 0, 12:01 doesn't end up 12:1

Parameters

n(Number)

Return

String

dateFromDB

static public function dateFromDB(dbdate:String):Date

converts a DB formatted date string into a Flash Date Object.

Parameters

Return

Date

getHoursAmPm

static public function getHoursAmPm(hour24:Number):Object

Takes 24hr hours and converts to 12 hour with am/pm.

Parameters

hour24(Number)

Return

Object

dateDiff

static public function dateDiff(d1:Date, d2:Date):Number

Get the differences between two Dates in milliseconds.

Parameters

d1(Date)
d2(Date) optional [default: now]

Return

Number - difference between two dates in ms

isValidAge

static public function isValidAge(year:Number, month:Number, day:Number, requiredAge:Number):Boolean

Check if birthdate entered meets required age.

Parameters

year(Number)
month(Number)
day(Number)
requiredAge(Number)

Return

Boolean

isValidDate

static public function isValidDate(year:Number, month:Number, day:Number, mustBeInPast:Boolean):Boolean

Check if a valid date can be created with inputs.

Parameters

year(Number)
month(Number)
day(Number)
mustBeInPast(Boolean)

Return

Boolean

getTotalDaysInMonth

static public function getTotalDaysInMonth(year:Number, month:Number):Number

Return the number of dates in a specific month.

Parameters

year(Number)
month(Number)

Return

Number

getTotalDaysInYear

static public function getTotalDaysInYear(year:Number):Number

Returns the number of days in a specific year.

Parameters

year(Number)

Return

Number