DateUtils
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Classpath: | org.asapframework.util.DateUtils |
| File last modified: | Thursday, 07 September 2006, 16:24:58 |
A collection of utility methods for the Date class.
Example:
- DateUtils has static methods. To use them, import the class and write for instance:
var d:Date = DateUtils.stringToDate( "23-3-2004" );
Summary
Class properties
- sMonthsLoCase : Object
- sMonthsUpCase : Object
- sShortMonths : Object
Class methods
- stringToDate (inString:String, inDelimiter:String) : Date
- Creates a Date object from a string.
- getDaysSinceNow (inDate:Date) : Number
- Returns the number of days elapsed since the current moment.
- getMonthAsString (inMonth:Number, inLang:String, inCaps:Boolean) : String
- Returns the full name of the month for a given month number and language.
- getShortMonthAsString (inMonth:Number, inLang:String) : String
- Returns the short name of the month for a given month number and language.
- isEqual (a:Date, b:Date) : Boolean
- Compares two Dates.
Class properties
sMonthsLoCase
static private sMonthsLoCase:Object
(read)
sMonthsUpCase
static private sMonthsUpCase:Object
(read)
sShortMonths
static private sShortMonths:Object
(read)
Class methods
getDaysSinceNow
static function getDaysSinceNow (
inDate:Date) : Number
Returns the number of days elapsed since the current moment.
Parameters:
date:
Another moment in the past or future.
Returns:
- A float value of the difference in days.
Usage:
-
var daysPassed:Number = DateUtils.getDaysSinceNow( myOtherDateObj );
To get the positive number of days up till a moment in the future ("getDaysFromNow"), use:var myFutureDate:Date = DateUtils.stringToDate( "31-12-2040" ); var daysLeft:Number = -DateUtils.getDaysSinceNow( myFutureDate );
getMonthAsString
static function getMonthAsString (
inMonth:Number,
inLang:String,
inCaps:Boolean) : String
Returns the full name of the month for a given month number and language.
Parameters:
month :
Number indicating which month to get (zero based).
language:
The language in which the month name should be returned. Supported: "eng", "ger", "fre", "spa", "ita" and "dut"; "eng" is default when no language is given.
caps :
Optional, set to 'true' to receive month name in capitals.
Returns:
- The name of the month, for example "March" for month 2, or null if none was found
getShortMonthAsString
static function getShortMonthAsString (
inMonth:Number,
inLang:String) : String
Returns the short name of the month for a given month number and language.
Parameters:
month :
Number indicating which month to get (zero based).
language:
The language in which the month name should be returned. Supported: "eng" and "dut"; "eng" is default when no language is given.
Returns:
- The short name of the month, for example "Mar" for month 2, or null if none was found
isEqual
static function isEqual (
a:Date,
b:Date) : Boolean
Compares two Dates.
Parameters:
a:
first Date to compare
b:
second Date to compare
Returns:
- True is both Dates are equal; false if they are not.
stringToDate
static function stringToDate (
inString:String,
inDelimiter:String) : Date
Creates a Date object from a string.
Parameters:
string :
A string with the format "day-month-year".
delimiter:
Optional, the delimiter used to seperate the day, month and year parts. When left empty, the default is "-".
Returns:
- A Date object
Usage:
-
var d:Date = DateUtils.stringToDate( "23-3-2004" );
This returns (when traced):Tue Mar 23 18:09:14 GMT+0100 2004.
Hours, minutes and seconds are set to 0.
To do:
- International date format (order of date parts)
- UTC date format