# Date ActionScript Class

This class implements the Date object.

## The Methods of the Class

getDate()

  Returns a Date's day-of-month from 1 to 31 according to local time.

getDay()

  Returns the day-of-the-week for a Date, according to local time, in the range 0-6 where 0 means Sunday and 6 means Saturday.

getFullYear()

  Returns the Gregorian year number for a Date, according to local time. Since Gnash currently uses POSIX date routines internally, this probably only works for dates from 13 Dec 1901 to 19 Jan 2038.

getHours()

  Returns the hour-of-the-day for a Date, according to local time, in the range 0-23.

getMilliseconds()

  Returns the milliseconds component of a Date as an integer in the range 0-999.

getMinutes()

  Returns the minutes-past-the-hour for a Date, according to local time, in the range 0-59.

getMonth()

  Returns the month of the year for a Date, according to local time, in the range 0-11 where 0 means January and 11 means December.

getSeconds()

  Returns the seconds past the minute for a Date, in the range 0-59.

getTime()

  Returns the number of milliseconds elapsed since 1 Jan 1970 00:00:00 in Universal Coordinated Time, as a floating point number: fractions of milliseconds are included. Negative values indicate times before 1 Jan 1970.

getTimezoneOffset()

  Returns the difference between Universal Coordinated Time and the local time represented by a Date, including Daylight Savings Time if it was in effect at that time in the current locale. The return value is in minutes; negative for timezones east of Greenwich and positive for those west of Greenwich.

  For example in the GMT+1 timezone, one hour east of Greenwich, for a time when DST was not in effect, the result would be -60. In the same timezone when DST is in effect, the extra hour in advance of UTC makes the value -120. Positive values are returned for locales west of Greenwich.

getUTCDate()

  Returns a Date's day-of-month from 1 to 31, according to Universal Coordinated Time.

getUTCDay()

  Returns the day-of-the-week for a Date, according to local time, in the range 0-6 where 0 means Sunday and 6 means Saturday.

getUTCFullYear()

  Returns the Gregorian year number for a Date, according to Universal Coordinated Time. Since Gnash currently uses POSIX date routines internally, this probably only works for dates from 13 Dec 1901 to 19 Jan 2038.

getUTCHours()

  Returns the hour-of-the-day for a Date, according to Universal Coordinated Time, in the range 0-23.

getUTCMilliseconds()

  Returns the milliseconds component of a Date as an integer in the range 0-999.

getUTCMinutes()

  Returns the minutes-past-the-hour for a Date, according to Universal Coordinated Time, in the range 0-59.

getUTCMonth()

  Returns the month of the year for a Date, according to Universal Coordinated Time, in the range 0-11 where 0 means January and 11 means December.

getUTCSeconds()

  Returns the seconds past the minute for a Date, in the range 0-59.

getYear()

  Returns the number of Gregorian years elapsed between 1900 and a Date, according to local time.

  For dates past 1st Jan 2000 it returns values from 100 onwards; for years before 1900 it returns negative values.

  This function is a historical wart left over from the days when nobody could believe we would still be using SWF in 2000.

setDate(dayofmonth)

  Sets the day-of-month for a Date object, in the range 1-31, leaving the year, month, and time-of-day unchanged for valid values.

  If dayofmonth is greater than the number of days in the month in question, it wraps into the following month: for example, trying to set the 35th to a date in January will result in the 4th of February. If it is zero or negative, this will take the Date back to a previous month and possibly a previous year.

  If there are no parameters to setDate, if dayofmonth is not of type Number (or a String that contains a decimal number or the Boolean values "true" and "false", which behave the same as 1 and 0) is an infinity or NotANumber, this sets the value of the Date object to "Not A Number", which is converted to a string as "Invalid date".

setFullYear(year,[month[,dayofmonth]])

  If a single parameter is given, this sets the Gregorian year number for a Date, normally leaving the month and day-of-month unchanged.

  When changing from a leap year to a non-leap year when the date is set to 29th February, the resulting date is 1st March of the same year.

  If month, and maybe dayofmonth, are also given, they simultaneously set the month (and day of month), following the usual rules whereby excessively large or negative values carry over to affect the month or year and still give a valid date.

  If any supplied value cannot be converted to a valid number, the Date's value is set to NotANumber.

setHours(hour)

  Sets the hour-of-the-day, normally in the range 0-23, leaving the calendar date and minutes/seconds unchanged.

  Values greater than 23 will make the date roll over to one of the following days; negative values will result in previous dates. If no parameter is given, or if it is not of a type that can be converted to a number, the resulting date value is NotANumber, which prints as "Invalid date".

setMilliseconds()

  Sets the milliseconds with a resolution of one millisecond: fractional parts of a millisecond are ignored.

  The parameter is normally a value from 0-999, but values outside this range will carry over into, or borrow from, the seconds (and minutes, hours etc if necessary).

  If no parameters are given, or if the parameter cannot be converted to a number, the Date's value is set to NotANumber. Any extra parameters are ignored.

setMinutes(minutes[,seconds[,milliseconds]])

  Sets the minutes-past-the-hour normally in the range 0-59, leaving the calendar date and hour/seconds unchanged.

  "Minutes" greater than 59 carry over into the hours (and may consequently advance the date); simiarly, negative values borrow from them.

  The optional second and third parameters simultaneously set the seconds and millisecond components, with similar carry/borrow if they are outside the ranges 0-59 and 0-999; fractions of seconds and milliseconds are ignored.

  If no parameter is given, or if it is not of a type that can be converted to a number, the resulting date value is NotANumber, which prints as "Invalid date". Gnash differs from the commercial Flash player in this, which, given a non-numeric value for "minutes", returns a seemingly random date such as 9th December, 2077 BC.

setMonth(month[,day])

  Sets the month of the year, normally in the range 0-11, leaving the year and time of day (in localtime) unchanged.

  Values greater than 11 will make the date roll over into a following year; negative values will result in previous years.

  If only the month is given, the new month has less days that the old, and the day-of-month is beyond the end of the new month, the date wraps over into the first days of the month after the specified one. Gnash differs in this from the commercial player, which leaves the date set to the last day of the requested month.

  If no parameter is given, or if it is not of a type that can be converted to a number, the month is set to January without changing the year.

  If the optional extra parameter "day" is given, both the month and day-of-month are set. As usual, day numbers beyond the last day of the selected month wrap over into the following month(s), and negative values take us back to previous months and possibly years.

  Unlike the "month" parameter, non-numeric values for "day" result in the Date's value being set to NotANumber.

  Any further parameters are ignored.

setSeconds(seconds[,milliseconds])

  Sets the seconds component of a Date. If the value of "seconds" is from 0-59, the hours and minutes will be unchanged.

  An optional extra parameter can be used to simultanously set the milliseconds, though only to a precision of one millisecond: fractions of milliseconds can be given but are ignored). Likewise, any fractional part of a second is ignored.

  As usual, values outside the range 0-999 for milliseconds are (added or subtracted) from the seconds, and values outside the range 0-59 for the seconds carry over into the minutes, hours etc.

  Non-numerical values for "seconds" or "milliseconds" result in the Date's value being set to NotANumber.

setTime()

  Sets a Date object to a specified number of milliseconds since 1 Jan 1970 in Universal Coordinated Time. Fractions of milliseconds are ignored; the only way to set a a date to sub-millisecond accuracy is to use the single-argument version of the Date constructor.

  If no parameters are supplied, or if the parameter cannot be converted to a number, the Date's value is set to NotANumber.

setUTCDate()

  Is the same as setDate(), but specifying the time in Universal Coordinated Time.

setUTCFullYear()

  Is the same as setFullYear(), but specifying the time in Universal Coordinated Time.

setUTCHours()

  Is the same as setHours(), but specifying the time in Universal Coordinated Time.

setUTCMilliseconds()

  Is the same as setMilliseconds().

setUTCMinutes()

  Is the same as setMinutes(), but specifying the time in Universal Coordinated Time.

  This differs from setMinutes in countries that have a time offset that is not a whole number of hours and on Lord Howe Island which also has daylight savings time of half an hour.

setUTCMonth()

  Is the same as setMonth(), but specifying the time in Universal Coordinated Time.

setUTCSeconds()

  Is the same as setSeconds(),

setYear(year[,month[,dayofmonth]])

  Is the same as setFullYear(), except that values from 0 to 99 specify the years 1900 to 1999, and negative values specify a year prior to 1900. Thus the only way to specify the year 55AD with this method is to use -1845.

toString()

  Converts a Date object to a printable string in the form "Thu Jan 1 00:00:00 GMT+0000 1970" in local time, according to the local timezone and whether Daylight Saving Time was in force at the time in question.

  If the Date's value is NotANumber or Infinity, the string "Invalid Date" is returned.

UTC(year,month[,dayofmonth[,hour[,minutes[,seconds[,milliseconds]]]]])

  Is a static function that converts the specified time, expressed in Universal Coordinated Time, to a Date value. It is most often used in conjunction with the Date constructor or the setTime method, to create a Date object according to UTC.

  All parameters are 0-based except "month" which is 1-based, and the usual carry/borrow rules apply for oversized and negative values.

  A missing day-of-month defaults to the first of the month; the other parameters default to zero.

  If less than two paramemters are supplied, or if any supplied parameters cannot be converted to numeric values, the Date's value is set to NotANumber.

## Date Class Conformance

Class Name | Conformance
--- | ---
getDate() | Implemented.
getDay() | Implemented.
getFullYear() | Implemented.
getHours() | Implemented.
getMilliseconds() | Implemented.
getMinutes() | Implemented.
getMonth() | Implemented.
getSeconds() | Implemented.
getTime() | Implemented.
getTimezoneOffset() | Implemented.
getUTCDate() | Implemented.
getUTCDay() | Implemented.
getUTCFullYear() | Implemented.
getUTCHours() | Implemented.
getUTCMilliseconds() | Implemented.
getUTCMinutes() | Implemented.
getUTCMonth() | Implemented.
getUTCSeconds() | Implemented.
getYear() | Implemented.
setDate() | Implemented.
setFullYear() | Implemented.
setHours() | Implemented.
setMilliseconds() | Implemented.
setMinutes() | Implemented. The commercial player, given d.setMinutes(), leaves the date set to a random value such as 9th December 2077 BC. Gnash gives NotANumber, in the same way as all the other functions.
setMonth() | Implemented.
setSeconds() | Implemented.
setTime() | Implemented.
setUTCDate() | Implemented.
setUTCFullYear() | Implemented.
setUTCHours() | Implemented.
setUTCMilliseconds() | Implemented.
setUTCMinutes() | Implemented. See setMinutes above.
setUTCMonth() | Implemented.
setUTCSeconds() | Implemented.
setYear() | Implemented.
toString() | Implemented.
UTC() | Implemented. The commercial player, given Date.UTC(Infinity, 0), returns -6.77681005679712e+19; Gnash returns NAN if any parameter is non-numeric.