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 >

Subversion Id

$Id: DateFormat.as 37 2006-05-10 19:29:32Z kluck $

Summary
com. kelvinluck. util. DateFormatJust a very simple class to hold some functions for formating a Flash Date object.
DateFormatPrivate constructor to prevent you creating instances of this class
dateToIsoStatic function which converts a given Date object into an ISO / MySQL Date Stamp format (e.g.
isoToDateStatic function which converts a given ISO / MySQL Date Stamp Format String (e.g.
secsToDateStatic function which converts a number of seconds into a Date object.
_zeroPadSimple 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,
hideTime: Boolean):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
hideTimeWhether to include the time in the generated date - defaults to true

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,
hideTime: Boolean):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.