XDate

Since Virtual Ticket uses separate date and time types, it is recommended that you use the XDate object instead of the Date object when working with dates.

Core object

Created by

new XDate();
new XDate( yr_num );
new XDate( yr_num, mo_num );
new XDate( yr_num, mo_num, day_num );

Parameters

Parameter Description
yr_num, mo_num, day_num Integer values representing part of a date. As an integer value, the month is represented by 0 to 11 with 0 = January and 11 = December.

Description

The XDate object is designed to support the representation of dates; it does not support time representation as its cousin the Date object does.

If you supply no arguments, the constructor creates an XDate object for today's date according to local time. If you supply some arguments but not others, the missing arguments are set to the minimum acceptable value.

The XDate object provides uniform behavior across platforms.

For compatibility with millennium calculations (in other words, to take into account the year 2000), you should always specify the year in full; for example, use 1998, not 98. To assist you in specifying the complete year, MetaScript includes the methods getFullYear, and setFullYear.

Example

The following example displays the date difference between dateA and dateB in days.

Property Summary

Property Description
constructor Specifies the function that creates an object's prototype.
prototype Allows the addition of properties to a XDate object.

Method Summary

Method Description
addDays Add days to the specified XDate object.
addMonths Add Months to the specified XDate object.
addYears Add Years to the specified XDate object.
getDate Returns the day of the month for the specified date according to local time.
getFullYear Returns the year of the specified date according to local time.
getMonth Returns the month in the specified date according to local time.
setDate Sets the day of the month for a specified date according to local time.
setFullYear Sets the full year for a specified date according to local time.
setMonth Sets the month for a specified date according to local time.
toSource Returns an object literal representing the specified XDate object; you can use this value to create a new object. Overrides the Object.toSource method.
toString Returns a string representing the specified XDate object. Overrides the Object.toString method.
valueOf Returns the primitive value of a XDate object. Overrides the Object.valueOf method.

In addition, this object inherits the Object.watch and Object.unwatch methods from Object.

See Also

XTime, ServerDate

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.