com. kelvinluck. util. DateFormat

Just a very simple class to hold some functions for formating a Flash Date object.

No need to create instances of the class - just use the static methods it provides...

Licence

This code and documentation is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0.  http://creativecommons.org/licenses/by-nc-sa/2.0/

Version

0.1.0

Author

Kelvin Luck < kelvin at kelvinluck dot com >

Summary
Just a very simple class to hold some functions for formating a Flash Date object.
Private constructor to prevent you creating instances of this class
Static function which converts a given Date object into an ISO / MySQL Date Stamp format (e.g.
Static function which converts a given ISO / MySQL Date Stamp Format String (e.g.
Static function which converts a number of seconds into a Date object.
Simple function to make sure a number is the right amount of characters long - used internally by dateToIso.

DateFormat

private function DateFormat()

Private constructor to prevent you creating instances of this class

dateToIso

public static function dateToIso(date: Date):String

Static function which converts a given Date object into an ISO / MySQL Date Stamp format (e.g.  “yyyy-mm-dd hh:mm:ss”)

Parameters

dateThe Date to convert

Returns

The ISO / MySQL Date Stamp Format String.

isoToDate

public static function isoToDate(dateStr: String):Date

Static function which converts a given ISO / MySQL Date Stamp Format String (e.g.  “yyyy-mm-dd hh:mm:ss”) into a Date object

Parameters

dateStrThe ISO / MySQL Date Stamp Format String

Returns

The converted Date object.

secsToDate

public static function secsToDate(secs):Date

Static function which converts a number of seconds into a Date object.

Parameters

secsThe number of seconds since 1970.  Purposefully not strongly typed as the whole point of this very simple function is to save on typing in the cases you may need it.

Returns

The converted Date object.

_zeroPad

private static function _zeroPad(value: Number):String

Simple function to make sure a number is the right amount of characters long - used internally by dateToIso.

Parameters

valueThe number you want to zero pad.

TODO

Maybe add a second parameter which is how many zeros you want to pad it with?

private function DateFormat()
Private constructor to prevent you creating instances of this class
public static function dateToIso(date: Date):String
Static function which converts a given Date object into an ISO / MySQL Date Stamp format (e.g.
public static function isoToDate(dateStr: String):Date
Static function which converts a given ISO / MySQL Date Stamp Format String (e.g.
public static function secsToDate(secs):Date
Static function which converts a number of seconds into a Date object.
private static function _zeroPad(value: Number):String
Simple function to make sure a number is the right amount of characters long - used internally by dateToIso.