release 0.5.4
[swfdec.git] / test / trace / date.as
blob159453498db2e6f9303babe8eb16be93f2cf0d67
1 // makeswf -v 5 -r 1 -o date-5.swf date.as
2 // makeswf -v 6 -r 1 -o date-6.swf date.as
3 // makeswf -v 7 -r 1 -o date-7.swf date.as
5 #include "values.as"
7 function traced (d)
9 trace (d.getTime () + " " + d.valueOf () + ": " + d.toString ());
10 trace (d.getFullYear () + "/" + d.getYear () + "-" + d.getMonth () + "-" + d.getDate () + " " + d.getDay () + " " + d.getHours () + ":" + d.getMinutes () + ":" + d.getSeconds () + "." + d.getMilliseconds ());
11 trace (d.getUTCFullYear () + "/" + d.getUTCYear () + "-" + d.getUTCMonth () + "-" + d.getUTCDate () + " " + d.getUTCDay () + " " + d.getUTCHours () + ":" + d.getUTCMinutes () + ":" + d.getUTCSeconds () + "." + d.getUTCMilliseconds ());
14 function p (val)
16 return val + " (" + typeof (val) + ")";
19 yearValues = [1983, 83, 0, 100, 99, 101, -100, -500, -271823, -271822, -271821, 275759, 275760, 275761, 100000000000000, -100000000000000];
20 yearValues = yearValues.concat (values);
21 monthValues = [5, 0, 11, 12, -1, 20, -20];
22 monthValues = monthValues.concat (values);
23 dateValues = [25, 1, 10, 29, 30, 31, 32, 0, -1, 200, -20];
24 dateValues = dateValues.concat (values);
25 hourValues = [13, 0, 5, 19, 23, -1, 24, 30, -20];
26 hourValues = hourValues.concat (values);
27 minuteValues = [50, 0, 10, 48, 59, -1, 60, -20, 200];
28 secondValues = minuteValues = minuteValues.concat (values);
29 millisecondValues = [300, 0, 12, 123, 580, 900, 934, 999, -1, 1000, 3123, -213];
30 millisecondValues = millisecondValues.concat (values);
32 // Date.UTC
34 for (i = 0; i < yearValues.length; i++) {
35 trace ("Date.UTC (" + p (yearValues[i]) +")");
36 val = Date.UTC (yearValues[i]);
37 trace (val);
38 if (val != undefined)
39 traced (new Date (val));
40 trace ("Date.UTC (" + p (yearValues[i]) + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
41 hourValues[0] + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
42 millisecondValues[0] + ")");
43 val = Date.UTC (yearValues[i], monthValues[0], dateValues[0], hourValues[0], minuteValues[0],
44 secondValues[0], millisecondValues[0]);
45 trace (val);
46 if (val != undefined)
47 traced (new Date (val));
50 for (i = 0; i < monthValues.length; i++) {
51 trace ("Date.UTC (" + yearValues[0] + ", " + p (monthValues[i]) + ")");
52 trace (Date.UTC (yearValues[0], monthValues[i]));
53 trace ("Date.UTC (" + yearValues[0] + ", " + p (monthValues[i]) + ", " + dateValues[0] + ", " +
54 hourValues[0] + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
55 millisecondValues[0] + ")");
56 trace (Date.UTC (yearValues[0], monthValues[i], dateValues[0], hourValues[0], minuteValues[0],
57 secondValues[0], millisecondValues[0]));
60 for (i = 0; i < dateValues.length; i++) {
61 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + p (dateValues[i]) + ")");
62 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[i]));
63 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + p (dateValues[i]) + ", " +
64 hourValues[0] + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
65 millisecondValues[0] + ")");
66 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[i], hourValues[0], minuteValues[0],
67 secondValues[0], millisecondValues[0]));
70 for (i = 0; i < hourValues.length; i++) {
71 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] +
72 ", " + p (hourValues[i]) + ")");
73 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[0], hourValues[i]));
74 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
75 p (hourValues[i]) + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
76 millisecondValues[0] + ")");
77 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[0], hourValues[i], minuteValues[0],
78 secondValues[0], millisecondValues[0]));
81 for (i = 0; i < minuteValues.length; i++) {
82 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
83 hourValues[0] + ", " + p (minuteValues[i]) + ")");
84 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[i]));
85 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
86 hourValues[0] + ", " + p (minuteValues[i]) + ", " + secondValues[0] + ", " +
87 millisecondValues[0] + ")");
88 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[i],
89 secondValues[0], millisecondValues[0]));
92 for (i = 0; i < secondValues.length; i++) {
93 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
94 hourValues[0] + ", " + minuteValues[0] + ", " + p (secondValues[i]) + ")");
95 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[0],
96 secondValues[i]));
97 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
98 hourValues[0] + ", " + minuteValues[0] + ", " + p (secondValues[i]) + ", " +
99 millisecondValues[0] + ")");
100 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[0],
101 secondValues[i], millisecondValues[0]));
104 for (i = 0; i < millisecondValues.length; i++) {
105 trace ("Date.UTC (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
106 hourValues[0] + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
107 p (millisecondValues[i]) + ")");
108 trace (Date.UTC (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[0],
109 secondValues[0], millisecondValues[i]));
112 // new Date ()
114 for (i = 0; i < yearValues.length; i++) {
115 // we can't test undefined first parameter, returns current time
116 if (typeof (yearValues[i]) == "undefined")
117 continue;
118 trace ("new Date (" + p (yearValues[i]) + ")");
119 traced (new Date (yearValues[i])); // Note: UTC here
120 trace ("new Date (" + p (yearValues[i]) + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
121 hourValues[0] + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
122 millisecondValues[0] + ")");
123 traced (new Date (yearValues[i], monthValues[0], dateValues[0], hourValues[0], minuteValues[0],
124 secondValues[0], millisecondValues[0]));
127 for (i = 0; i < monthValues.length; i++) {
128 trace ("new Date (" + yearValues[0] + ", " + p (monthValues[i]) + ")");
129 traced (new Date (yearValues[0], monthValues[i]));
130 trace ("new Date (" + yearValues[0] + ", " + p (monthValues[i]) + ", " + dateValues[0] + ", " +
131 hourValues[0] + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
132 millisecondValues[0] + ")");
133 traced (new Date (yearValues[0], monthValues[i], dateValues[0], hourValues[0], minuteValues[0],
134 secondValues[0], millisecondValues[0]));
137 for (i = 0; i < dateValues.length; i++) {
138 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + p (dateValues[i]) + ")");
139 traced (new Date (yearValues[0], monthValues[0], dateValues[i]));
140 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + p (dateValues[i]) + ", " +
141 hourValues[0] + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
142 millisecondValues[0] + ")");
143 traced (new Date (yearValues[0], monthValues[0], dateValues[i], hourValues[0], minuteValues[0],
144 secondValues[0], millisecondValues[0]));
147 for (i = 0; i < hourValues.length; i++) {
148 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[i] + ", " +
149 p (hourValues[i]) + ")");
150 traced (new Date (yearValues[0], monthValues[0], dateValues[0], hourValues[i]));
151 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
152 p (hourValues[i]) + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
153 millisecondValues[0] + ")");
154 traced (new Date (yearValues[0], monthValues[0], dateValues[0], hourValues[i], minuteValues[0],
155 secondValues[0], millisecondValues[0]));
158 for (i = 0; i < minuteValues.length; i++) {
159 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[i] + ", " +
160 hourValues[0] + ", " + p (minuteValues[i]) + ")");
161 traced (new Date (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[i]));
162 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
163 hourValues[0] + ", " + p (minuteValues[i]) + ", " + secondValues[0] + ", " +
164 millisecondValues[0] + ")");
165 traced (new Date (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[i],
166 secondValues[0], millisecondValues[0]));
169 for (i = 0; i < secondValues.length; i++) {
170 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[i] + ", " +
171 hourValues[0] + ", " + minuteValues[0] + ", " + p (secondValues[i]) + ")");
172 traced (new Date (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[0],
173 secondValues[i]));
174 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
175 hourValues[0] + ", " + minuteValues[0] + ", " + p (secondValues[i]) + ", " +
176 millisecondValues[0] + ")");
177 traced (new Date (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[0],
178 secondValues[i], millisecondValues[0]));
181 for (i = 0; i < millisecondValues.length; i++) {
182 trace ("new Date (" + yearValues[0] + ", " + monthValues[0] + ", " + dateValues[0] + ", " +
183 hourValues[0] + ", " + minuteValues[0] + ", " + secondValues[0] + ", " +
184 p (millisecondValues[0]) + ")");
185 traced (new Date (yearValues[0], monthValues[0], dateValues[0], hourValues[0], minuteValues[0],
186 secondValues[0], millisecondValues[i]));
189 // set* functions
191 num_test_dates = 5;
192 function test_date (num)
194 if (num == 0) {
195 return new Date (yearValues[0], monthValues[0], dateValues[0],
196 hourValues[0], minuteValues[0], secondValues[0], millisecondValues[0]);
197 } else if (num == 1) {
198 return new Date (2005, 8, 20, NaN);
199 } else if (num == 2) {
200 return new Date (275762, 0, 1);
201 } else if (num == 3) {
202 return new Date (1804, 3, 24);
203 } else {
204 return new Date (-40, 1, 5);
208 for (var num = 0; num < num_test_dates; num++) {
209 for (var i = 0; i < yearValues.length; i++) {
210 var d = test_date (num);
211 trace ("test_date (" + num + ").setYear (" + p (yearValues[i]) + ")");
212 trace (d.setYear (yearValues[i]));
213 traced (d);
217 for (var num = 0; num < num_test_dates; num++) {
218 for (var i = 0; i < monthValues.length; i++) {
219 var d = test_date (num);
220 trace ("test_date (" + num + ").setMonth (" + p (monthValues[i]) + ")");
221 trace (d.setMonth (monthValues[i]));
222 traced (d);
226 for (var num = 0; num < num_test_dates; num++) {
227 for (var i = 0; i < dateValues.length; i++) {
228 var d = test_date (num);
229 trace ("test_date (" + num + ").setDate (" + p (dateValues[i]) + ")");
230 trace (d.setDate (dateValues[i]));
231 traced (d);
235 for (var num = 0; num < num_test_dates; num++) {
236 for (var i = 0; i < hoursValues.length; i++) {
237 var d = test_date (num);
238 trace ("test_date (" + num + ").setHours (" + p (hoursValues[i]) + ")");
239 trace (d.setHours (hoursValues[i]));
240 traced (d);
244 for (var num = 0; num < num_test_dates; num++) {
245 for (var i = 0; i < minutesValues.length; i++) {
246 var d = test_date (num);
247 trace ("test_date (" + num + ").setMinutes (" + p (minutesValues[i]) + ")");
248 trace (d.setMinutes (minutesValues[i]));
249 traced (d);
253 for (var num = 0; num < num_test_dates; num++) {
254 for (var i = 0; i < secondsValues.length; i++) {
255 var d = test_date (num);
256 trace ("test_date (" + num + ").setSeconds (" + p (secondsValues[i]) + ")");
257 trace (d.setSeconds (secondsValues[i]));
258 traced (d);
262 for (var num = 0; num < num_test_dates; num++) {
263 for (var i = 0; i < millisecondsValues.length; i++) {
264 var d = test_date (num);
265 trace ("test_date (" + num + ").setMilliseconds (" + p (millisecondsValues[i]) + ")");
266 trace (d.setMilliseconds (millisecondsValues[i]));
267 traced (d);
271 loadMovie ("FSCommand:quit", "");