2
<title>Date ActionScript Class</title>
5
This class implements the Date object.
8
<sect5 id="datemethods">
9
<title>The Methods of the Class</title>
14
<term>getDate()</term>
17
Returns a Date's day-of-month from 1 to 31
18
according to local time.
27
Returns the day-of-the-week for a Date,
28
according to local time,
29
in the range 0-6 where 0 means Sunday and 6 means Saturday.
35
<term>getFullYear()</term>
38
Returns the Gregorian year number for a Date,
39
according to local time.
40
Since Gnash currently uses POSIX date routines internally,
41
this probably only works for dates from
42
13 Dec 1901 to 19 Jan 2038.
48
<term>getHours()</term>
51
Returns the hour-of-the-day for a Date,
52
according to local time,
59
<term>getMilliseconds()</term>
62
Returns the milliseconds component of a Date
63
as an integer in the range 0-999.
69
<term>getMinutes()</term>
72
Returns the minutes-past-the-hour for a Date,
73
according to local time,
80
<term>getMonth()</term>
83
Returns the month of the year for a Date,
84
according to local time,
85
in the range 0-11 where 0 means January and 11 means December.
91
<term>getSeconds()</term>
94
Returns the seconds past the minute for a Date,
101
<term>getTime()</term>
104
Returns the number of milliseconds elapsed since
105
1 Jan 1970 00:00:00 in Universal Coordinated Time,
106
as a floating point number: fractions of milliseconds
108
Negative values indicate times before 1 Jan 1970.
114
<term>getTimezoneOffset()</term>
117
Returns the difference between Universal Coordinated Time
118
and the local time represented by a Date, including
119
Daylight Savings Time if it was in effect at that time
120
in the current locale.
121
The return value is in minutes; negative for timezones east of
122
Greenwich and positive for those west of Greenwich.
125
For example in the GMT+1 timezone, one hour east of Greenwich,
126
for a time when DST was not in effect,
127
the result would be -60.
128
In the same timezone when DST is in effect,
129
the extra hour in advance of UTC makes the value -120.
130
Positive values are returned for locales west of Greenwich.
136
<term>getUTCDate()</term>
139
Returns a Date's day-of-month from 1 to 31,
140
according to Universal Coordinated Time.
146
<term>getUTCDay()</term>
149
Returns the day-of-the-week for a Date,
150
according to local time,
151
in the range 0-6 where 0 means Sunday and 6 means Saturday.
157
<term>getUTCFullYear()</term>
160
Returns the Gregorian year number for a Date,
161
according to Universal Coordinated Time.
162
Since Gnash currently uses POSIX date routines internally,
163
this probably only works for dates from
164
13 Dec 1901 to 19 Jan 2038.
170
<term>getUTCHours()</term>
173
Returns the hour-of-the-day for a Date,
174
according to Universal Coordinated Time,
181
<term>getUTCMilliseconds()</term>
184
Returns the milliseconds component of a Date
185
as an integer in the range 0-999.
191
<term>getUTCMinutes()</term>
194
Returns the minutes-past-the-hour for a Date,
195
according to Universal Coordinated Time,
202
<term>getUTCMonth()</term>
205
Returns the month of the year for a Date,
206
according to Universal Coordinated Time,
207
in the range 0-11 where 0 means January and 11 means December.
213
<term>getUTCSeconds()</term>
216
Returns the seconds past the minute for a Date,
223
<term>getYear()</term>
226
Returns the number of Gregorian years elapsed between 1900
228
according to local time.
231
For dates past 1st Jan 2000 it returns values from 100 onwards;
232
for years before 1900 it returns negative values.
235
This function is a historical wart left over from the days when
236
nobody could believe we would still be using SWF in 2000.
242
<term>setDate(dayofmonth)</term>
245
Sets the day-of-month for a Date object,
246
in the range 1-31, leaving the year, month, and
247
time-of-day unchanged for valid values.
250
If dayofmonth is greater than the number of days in the
251
month in question, it wraps into the following month:
252
for example, trying to set the 35th to a date in January
253
will result in the 4th of February.
254
If it is zero or negative, this will take the Date back
255
to a previous month and possibly a previous year.
258
If there are no parameters to setDate,
259
if dayofmonth is not of type Number
260
(or a String that contains a decimal number
261
or the Boolean values "true" and "false",
262
which behave the same as 1 and 0)
263
is an infinity or NotANumber,
264
this sets the value of the Date object to "Not A Number",
265
which is converted to a string as "Invalid date".
271
<term>setFullYear(year,[month[,dayofmonth]])</term>
274
If a single parameter is given, this
275
sets the Gregorian year number for a Date,
276
normally leaving the month and day-of-month unchanged.
279
When changing from a leap year to a non-leap year
280
when the date is set to 29th February,
281
the resulting date is 1st March of the same year.
284
If month, and maybe dayofmonth, are also given, they
285
simultaneously set the month (and day of month), following
286
the usual rules whereby excessively large or negative values
287
carry over to affect the month or year and still give a
291
If any supplied value cannot be converted to a valid number,
292
the Date's value is set to NotANumber.
298
<term>setHours(hour)</term>
301
Sets the hour-of-the-day, normally in the range 0-23,
302
leaving the calendar date and minutes/seconds unchanged.
305
Values greater than 23 will make the date roll over to one of
306
the following days; negative values will result in previous
308
If no parameter is given, or if it is not of a type that can be
309
converted to a number, the resulting date value is NotANumber,
310
which prints as "Invalid date".
316
<term>setMilliseconds()</term>
319
Sets the milliseconds with a resolution of one millisecond:
320
fractional parts of a millisecond are ignored.
323
The parameter is normally a value from 0-999, but values
324
outside this range will carry over into, or borrow from,
325
the seconds (and minutes, hours etc if necessary).
328
If no parameters are given, or if the parameter cannot
329
be converted to a number, the Date's value is set to
330
NotANumber. Any extra parameters are ignored.
336
<term>setMinutes(minutes[,seconds[,milliseconds]])</term>
339
Sets the minutes-past-the-hour normally in the range 0-59,
340
leaving the calendar date and hour/seconds unchanged.
343
"Minutes" greater than 59 carry over into the hours (and
344
may consequently advance the date);
345
simiarly, negative values borrow from them.
348
The optional second and third parameters simultaneously set
349
the seconds and millisecond components,
350
with similar carry/borrow if they are outside the ranges
352
fractions of seconds and milliseconds are ignored.
355
If no parameter is given, or if it is not of a type that can be
356
converted to a number, the resulting date value is NotANumber,
357
which prints as "Invalid date".
358
Gnash differs from the commercial Flash player in this,
359
which, given a non-numeric value for "minutes",
360
returns a seemingly random date such as 9th December, 2077 BC.
366
<term>setMonth(month[,day])</term>
369
Sets the month of the year, normally in the range 0-11,
370
leaving the year and time of day (in localtime) unchanged.
373
Values greater than 11 will make the date roll over into a
374
following year; negative values will result in previous
378
If only the month is given, the new month has less days that
379
the old, and the day-of-month is beyond the end of the new
380
month, the date wraps over into the first days of the month
381
after the specified one. Gnash differs in this from the
382
commercial player, which leaves the date set to the last day
383
of the requested month.
386
If no parameter is given, or if it is not of a type that can
387
be converted to a number, the month is set to January without
391
If the optional extra parameter "day" is given, both the
392
month and day-of-month are set. As usual, day numbers beyond
393
the last day of the selected month wrap over into the following
394
month(s), and negative values take us back to previous months
398
Unlike the "month" parameter, non-numeric values for "day"
399
result in the Date's value being set to NotANumber.
402
Any further parameters are ignored.
408
<term>setSeconds(seconds[,milliseconds])</term>
411
Sets the seconds component of a Date.
412
If the value of "seconds" is from 0-59, the hours and
413
minutes will be unchanged.
416
An optional extra parameter can be used to simultanously
417
set the milliseconds, though only to a precision of
418
one millisecond: fractions of milliseconds can be given
419
but are ignored). Likewise, any fractional part of a second
423
As usual, values outside the range 0-999 for milliseconds
424
are (added or subtracted) from the seconds,
425
and values outside the range 0-59 for the seconds carry over
426
into the minutes, hours etc.
429
Non-numerical values for "seconds" or "milliseconds"
430
result in the Date's value being set to NotANumber.
436
<term>setTime()</term>
439
Sets a Date object to a specified number of milliseconds
440
since 1 Jan 1970 in Universal Coordinated Time.
441
Fractions of milliseconds are ignored;
442
the only way to set a a date to sub-millisecond accuracy
443
is to use the single-argument version of the Date constructor.
446
If no parameters are supplied, or if the parameter cannot be
447
converted to a number, the Date's value is set to NotANumber.
453
<term>setUTCDate()</term>
456
Is the same as setDate(),
457
but specifying the time in Universal Coordinated Time.
463
<term>setUTCFullYear()</term>
466
Is the same as setFullYear(),
467
but specifying the time in Universal Coordinated Time.
473
<term>setUTCHours()</term>
476
Is the same as setHours(),
477
but specifying the time in Universal Coordinated Time.
483
<term>setUTCMilliseconds()</term>
486
Is the same as setMilliseconds().
492
<term>setUTCMinutes()</term>
495
Is the same as setMinutes(),
496
but specifying the time in Universal Coordinated Time.
499
This differs from setMinutes in countries that have
500
a time offset that is not a whole number of hours and on
501
Lord Howe Island which also has daylight savings time of
508
<term>setUTCMonth()</term>
511
Is the same as setMonth(),
512
but specifying the time in Universal Coordinated Time.
518
<term>setUTCSeconds()</term>
521
Is the same as setSeconds(),
527
<term>setYear(year[,month[,dayofmonth]])</term>
530
Is the same as setFullYear(), except that values from
531
0 to 99 specify the years 1900 to 1999, and negative values
532
specify a year prior to 1900. Thus the only way to specify
533
the year 55AD with this method is to use -1845.
539
<term>toString()</term>
542
Converts a Date object to a printable string in the form
543
"Thu Jan 1 00:00:00 GMT+0000 1970" in local time, according to
544
the local timezone and whether Daylight Saving Time
545
was in force at the time in question.
548
If the Date's value is NotANumber or Infinity,
549
the string "Invalid Date" is returned.
555
<term>UTC(year,month[,dayofmonth[,hour[,minutes[,seconds[,milliseconds]]]]])</term>
558
Is a static function that converts the specified time,
559
expressed in Universal Coordinated Time,
560
to a Date value. It is most often used in conjunction with
561
the Date constructor or the setTime method, to create a
562
Date object according to UTC.
565
All parameters are 0-based except "month" which is 1-based,
566
and the usual carry/borrow rules apply for oversized and
570
A missing day-of-month defaults to the first of the month;
571
the other parameters default to zero.
574
If less than two paramemters are supplied, or if any supplied
575
parameters cannot be converted to numeric values, the Date's
576
value is set to NotANumber.
584
<sect5 id="dateconf">
585
<title>Date Class Conformance</title>
588
<informaltable frame="all">
589
<?dbhtml table-width="75%" ?>
594
<para>Class Name</para>
597
<para>Conformance</para>
603
<entry valign="top" align="left">
604
<para>getDate()</para>
606
<entry valign="top" align="center">
613
<entry valign="top" align="left">
614
<para>getDay()</para>
616
<entry valign="top" align="center">
623
<entry valign="top" align="left">
624
<para>getFullYear()</para>
626
<entry valign="top" align="center">
633
<entry valign="top" align="left">
634
<para>getHours()</para>
636
<entry valign="top" align="center">
643
<entry valign="top" align="left">
644
<para>getMilliseconds()</para>
646
<entry valign="top" align="center">
653
<entry valign="top" align="left">
654
<para>getMinutes()</para>
656
<entry valign="top" align="center">
663
<entry valign="top" align="left">
664
<para>getMonth()</para>
666
<entry valign="top" align="center">
673
<entry valign="top" align="left">
674
<para>getSeconds()</para>
676
<entry valign="top" align="center">
683
<entry valign="top" align="left">
684
<para>getTime()</para>
686
<entry valign="top" align="center">
693
<entry valign="top" align="left">
694
<para>getTimezoneOffset()</para>
696
<entry valign="top" align="center">
703
<entry valign="top" align="left">
704
<para>getUTCDate()</para>
706
<entry valign="top" align="center">
713
<entry valign="top" align="left">
714
<para>getUTCDay()</para>
716
<entry valign="top" align="center">
723
<entry valign="top" align="left">
724
<para>getUTCFullYear()</para>
726
<entry valign="top" align="center">
733
<entry valign="top" align="left">
734
<para>getUTCHours()</para>
736
<entry valign="top" align="center">
743
<entry valign="top" align="left">
744
<para>getUTCMilliseconds()</para>
746
<entry valign="top" align="center">
753
<entry valign="top" align="left">
754
<para>getUTCMinutes()</para>
756
<entry valign="top" align="center">
763
<entry valign="top" align="left">
764
<para>getUTCMonth()</para>
766
<entry valign="top" align="center">
773
<entry valign="top" align="left">
774
<para>getUTCSeconds()</para>
776
<entry valign="top" align="center">
783
<entry valign="top" align="left">
784
<para>getYear()</para>
786
<entry valign="top" align="center">
793
<entry valign="top" align="left">
794
<para>setDate()</para>
796
<entry valign="top" align="center">
803
<entry valign="top" align="left">
804
<para>setFullYear()</para>
806
<entry valign="top" align="center">
813
<entry valign="top" align="left">
814
<para>setHours()</para>
816
<entry valign="top" align="center">
823
<entry valign="top" align="left">
824
<para>setMilliseconds()</para>
826
<entry valign="top" align="center">
833
<entry valign="top" align="left">
834
<para>setMinutes()</para>
836
<entry valign="top" align="center">
841
The commercial player, given d.setMinutes(), leaves the
842
date set to a random value such as 9th December 2077 BC.
843
Gnash gives NotANumber, in the same way as all the
849
<entry valign="top" align="left">
850
<para>setMonth()</para>
852
<entry valign="top" align="center">
859
<entry valign="top" align="left">
860
<para>setSeconds()</para>
862
<entry valign="top" align="center">
869
<entry valign="top" align="left">
870
<para>setTime()</para>
872
<entry valign="top" align="center">
879
<entry valign="top" align="left">
880
<para>setUTCDate()</para>
882
<entry valign="top" align="center">
889
<entry valign="top" align="left">
890
<para>setUTCFullYear()</para>
892
<entry valign="top" align="center">
899
<entry valign="top" align="left">
900
<para>setUTCHours()</para>
902
<entry valign="top" align="center">
909
<entry valign="top" align="left">
910
<para>setUTCMilliseconds()</para>
912
<entry valign="top" align="center">
919
<entry valign="top" align="left">
920
<para>setUTCMinutes()</para>
922
<entry valign="top" align="center">
925
See setMinutes above.
930
<entry valign="top" align="left">
931
<para>setUTCMonth()</para>
933
<entry valign="top" align="center">
940
<entry valign="top" align="left">
941
<para>setUTCSeconds()</para>
943
<entry valign="top" align="center">
950
<entry valign="top" align="left">
951
<para>setYear()</para>
953
<entry valign="top" align="center">
960
<entry valign="top" align="left">
961
<para>toString()</para>
963
<entry valign="top" align="center">
970
<entry valign="top" align="left">
973
<entry valign="top" align="center">
978
The commercial player, given Date.UTC(Infinity, 0),
979
returns -6.77681005679712e+19;
980
Gnash returns NAN if any parameter is non-numeric.