DateObject

DateObject

Stores dates, both absolute and relative, and calculates differences.  This is a generic class that may be used in a variety of ways and is required by some API classes for date calculations.

__/ REQUIREMENTS \__

ActionScript 3.0 (or later)

__/ IMPORTS \__

com.bnm.api.CoreData flash.utils.*

__/ EXTENDS \__

com.bnm.api.CoreData

__/ IMPLEMENTS \__

nothing

__/ NOTICE \__

©opyright 2008 Bay New Media.  All rights, as stipulated in the The MIT License, are reserved.

This ActionScript library is licensed and released under the MIT License (http://www.opensource.org/licenses/mit-license.php).  Please refer to the accompanying text file “license.txt”, which should be distributed with every package and version of this library, for information on usage, distribution, copying, and other important information.

Please visit http://www.baynewmedia.com/ or email con.nosp@m.tact@baynewm.nosp@m.edia.com for information, questions, concerns, or bug reports.

__/ NOTES \__

This class is commented using the NaturalDocs documentation system.  It is intended to be easily read both from the direct source code and from an adaptation that is generated as hyperlinked HTML.  The NaturalDocs specification used in this class’ documentation is version 1.35 though older versions may probably be used safely.  For more information, please visit: http://www.naturaldocs.org/

The BNMAPI is officially available (primary sources) on Source Forge (http://sourceforge.net/projects/bnmapi/), on the Bay New Media site (http;//www.baynewmedia.com/), on the PeaBee project site (http://www.peabee.com/), and through the Bay New Media SVM repository server (visit http://www.baynewmedia.com/ for more information).  Downloads from other sources may not be complete or up-to-date.

If you’re interested in joining the BNMAPI project in any capacity (development, testing, distribution, etc.), please visit us on Source Forge or the Bay New Media web site.

Summary
DateObjectStores dates, both absolute and relative, and calculates differences.
Variables
_date(Date) An internal <Date> object against with which to perform date calculations or with which to compare other date objects (for deltas, for example).
Functions and Properties
DateObjectCreates a new DateObject instance.
isLaterCompares the current DateObject instance and the supplied parameter and returns TRUE if the current instance is later than the parameter DateObject.
isSameCompares the current DateObject instance and the supplied parameter and returns TRUE if both instance are the same date.
getDaysPerMonthReturns the days per month for the specified month and for the specified year, if supplied.
getMonthNumberReturns the number of the month (0-based) of the specified month string representation.
get dateIndexReturns a specially formatted unsigned integer that combines the DateObject’s date, month, and year values.
dateIndex
get dateReturns the date object used to store and manipulate date information for this class instance.
date
get dayReturns the day number of the current date object within the current date object’s month.
day
get monthReturns the month number of the current date object.
month
get yearReturns the full year of the current date object.
year
get dayOfWeekReturns the date of teh week associated with the current instance.
dayOfWeek
toStringThe default return handler for any object-to-string requests such as trace statements.

Variables

_date

private var _date: Date

(Date) An internal <Date> object against with which to perform date calculations or with which to compare other date objects (for deltas, for example).  This value is set, by default, to the current system date, but can be updated either via the constructor or via a setter.

Functions and Properties

DateObject

public function DateObject(... args)

Creates a new DateObject instance.  This instance can be used for a variety of date and relative date related tasks.

Parameters

date (untyped, optional): A date value to assign to this class instance.  This may be any value that can be passed to a standard <Date> object constructor.  If not passed, the current system date/time is assigned to this object at instantiation.

Returns

DateObject: A newly created class instance.

Broadcasts

nothing

Throws

nothing

Bubbles

no

isLater

public function isLater(date: DateObject):Boolean

Compares the current DateObject instance and the supplied parameter and returns TRUE if the current instance is later than the parameter DateObject.

Parameters

date (DateObject, required): The DateObject instance to compare to the current instance.

Returns

Boolean: TRUE if the `date` parameter is earlier in the calendar than this instance.  FALSE is returned if the current instance is earlier in the calendar, if both objects are the same date, or if the parameter supplied is incorrect.

Broadcasts

nothing

Throws

nothing

Bubbles

no

isSame

public function isSame(date: DateObject):Boolean

Compares the current DateObject instance and the supplied parameter and returns TRUE if both instance are the same date.

Parameters

date (DateObject, required): The DateObject instance to compare to the current instance.

Returns

Boolean: TRUE if the `date` parameter is the same date as the current instance.

Broadcasts

nothing

Throws

nothing

Bubbles

no

getDaysPerMonth

public function getDaysPerMonth (... args):uint

Returns the days per month for the specified month and for the specified year, if supplied.

Parameters

month (untyped, optional): Either a string representation of a month, or a numeric (0-based) month number.  If omitted, the current moth is used. year (uint, optional): The year for which to return the month for (this affected February during leap years).  If omitted, the current year is used.

Returns

uint: The number of days contained in the specified month.

Broadcasts

nothing

Throws

nothing

Bubbles

no

getMonthNumber

public function getMonthNumber(monthName: String):uint

Returns the number of the month (0-based) of the specified month string representation.  Valid month formats include “January”, “jan”, “Jan.”, etc.

Parameters

monthName (String, required): The name of the month to evaluate.

Returns

uint: The 0-based number of the month.  That is, 0=January, 1=February, 2=March, etc.  NULL is returned if an invalid month name is provided.

Broadcasts

nothing

Throws

nothing

Bubbles

no

get dateIndex

Returns a specially formatted unsigned integer that combines the DateObject’s date, month, and year values.  The format is YYYYMMDD.  This can allow the date object to be used as a unique index value in sorted data sets like numeric arrays.

Returns

uint: An unsigned integer index based on the date value of the instance.  This is in the format YYYYMMDD.  Values that are less than 10 are padded with an extra 0 to ensure that index valued and data length are retained.

Broadcasts

nothing

Throws

nothing

Bubbles

no

dateIndex

public function get dateIndex():uint

get date

Returns the date object used to store and manipulate date information for this class instance.  This is an instance of the system <Date> object.

Returns

Date: A standard system <Date> object.

Broadcasts

nothing

Throws

nothing

Bubbles

no

date

public function get date():Date

get day

Returns the day number of the current date object within the current date object’s month.

Returns

Number: The current day of the month of the date object associated with this DateObject instance.

Broadcasts

nothing

Throws

nothing

Bubbles

no

day

public function get day():Number

get month

Returns the month number of the current date object.

Returns

Number: The current month of the current DateObject instance.  This uses the same numbering scheme as the <Date.getMonth> method.

Broadcasts

nothing

Throws

nothing

Bubbles

no

month

public function get month():Number

get year

Returns the full year of the current date object.

Returns

Number: The current year of the current DateObject instance.  This uses the same numbering scheme as the <Date.getFullYear> method.

Broadcasts

nothing

Throws

nothing

Bubbles

no

year

public function get year():Number

get dayOfWeek

Returns the date of teh week associated with the current instance.

Returns

Number: The day of the week (starting with 0 representing Sunday) of the current DateObject instance.  This corresponds to the values returned by the <Date.getDay> method.

Broadcasts

nothing

Throws

nothing

Bubbles

no

dayOfWeek

public function get dayOfWeek():Number

toString

override public function toString():String

The default return handler for any object-to-string requests such as trace statements.

Parameters

none

Returns

String: The date string of the internal _date object, as generated by the `toDateString` method of the <Date> class.

Broadcasts

nothing

Throws

nothing

Bubbles

no

Provides facilities for data checking and conversion for all types of Flash data types.
private var _date: Date
(Date) An internal Date object against with which to perform date calculations or with which to compare other date objects (for deltas, for example).
public function DateObject(... args)
Creates a new DateObject instance.
public function isLater(date: DateObject):Boolean
Compares the current DateObject instance and the supplied parameter and returns TRUE if the current instance is later than the parameter DateObject.
public function isSame(date: DateObject):Boolean
Compares the current DateObject instance and the supplied parameter and returns TRUE if both instance are the same date.
public function getDaysPerMonth (... args):uint
Returns the days per month for the specified month and for the specified year, if supplied.
public function getMonthNumber(monthName: String):uint
Returns the number of the month (0-based) of the specified month string representation.
public function get dateIndex():uint
public function get date():Date
public function get day():Number
public function get month():Number
public function get year():Number
public function get dayOfWeek():Number
override public function toString():String
The default return handler for any object-to-string requests such as trace statements.