1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5function timezone(tz) {
6  var str = (new Date(2014, 0, 10)).toString();
7  if (tz == "CET") {
8    return str == "Fri Jan 10 2014 00:00:00 GMT+0100 (CET)";
9  }
10  if (tz == "BRT") {
11    return str == "Fri Jan 10 2014 00:00:00 GMT-0200 (BRST)";
12  }
13  if (tz == "PST") {
14    return str == "Fri Jan 10 2014 00:00:00 GMT-0800 (PST)";
15  }
16  return false;
17}
18
19if (timezone("CET")) {
20  assertEquals("Sat Mar 29 2014 22:59:00 GMT+0100 (CET)",
21               (new Date(2014, 2, 29, 22, 59)).toString());
22  assertEquals("Sat, 29 Mar 2014 21:59:00 GMT",
23               (new Date(2014, 2, 29, 22, 59)).toUTCString());
24  assertEquals("Sat Mar 29 2014 23:00:00 GMT+0100 (CET)",
25               (new Date(2014, 2, 29, 23, 0)).toString());
26  assertEquals("Sat, 29 Mar 2014 22:00:00 GMT",
27               (new Date(2014, 2, 29, 23, 0)).toUTCString());
28  assertEquals("Sat Mar 29 2014 23:59:00 GMT+0100 (CET)",
29               (new Date(2014, 2, 29, 23, 59)).toString());
30  assertEquals("Sat, 29 Mar 2014 22:59:00 GMT",
31               (new Date(2014, 2, 29, 23, 59)).toUTCString());
32  assertEquals("Sun Mar 30 2014 00:00:00 GMT+0100 (CET)",
33               (new Date(2014, 2, 30, 0, 0)).toString());
34  assertEquals("Sat, 29 Mar 2014 23:00:00 GMT",
35               (new Date(2014, 2, 30, 0, 0)).toUTCString());
36  assertEquals("Sun Mar 30 2014 00:59:00 GMT+0100 (CET)",
37               (new Date(2014, 2, 30, 0, 59)).toString());
38  assertEquals("Sat, 29 Mar 2014 23:59:00 GMT",
39               (new Date(2014, 2, 30, 0, 59)).toUTCString());
40  assertEquals("Sun Mar 30 2014 01:00:00 GMT+0100 (CET)",
41               (new Date(2014, 2, 30, 1, 0)).toString());
42  assertEquals("Sun, 30 Mar 2014 00:00:00 GMT",
43               (new Date(2014, 2, 30, 1, 0)).toUTCString());
44  assertEquals("Sun Mar 30 2014 01:59:00 GMT+0100 (CET)",
45               (new Date(2014, 2, 30, 1, 59)).toString());
46  assertEquals("Sun, 30 Mar 2014 00:59:00 GMT",
47               (new Date(2014, 2, 30, 1, 59)).toUTCString());
48  assertEquals("Sun Mar 30 2014 03:00:00 GMT+0200 (CEST)",
49               (new Date(2014, 2, 30, 2, 0)).toString());
50  assertEquals("Sun, 30 Mar 2014 01:00:00 GMT",
51               (new Date(2014, 2, 30, 2, 0)).toUTCString());
52  assertEquals("Sun Mar 30 2014 03:59:00 GMT+0200 (CEST)",
53               (new Date(2014, 2, 30, 2, 59)).toString());
54  assertEquals("Sun, 30 Mar 2014 01:59:00 GMT",
55               (new Date(2014, 2, 30, 2, 59)).toUTCString());
56  assertEquals("Sun Mar 30 2014 03:00:00 GMT+0200 (CEST)",
57               (new Date(2014, 2, 30, 3, 0)).toString());
58  assertEquals("Sun, 30 Mar 2014 01:00:00 GMT",
59               (new Date(2014, 2, 30, 3, 0)).toUTCString());
60  assertEquals("Sun Mar 30 2014 03:59:00 GMT+0200 (CEST)",
61               (new Date(2014, 2, 30, 3, 59)).toString());
62  assertEquals("Sun, 30 Mar 2014 01:59:00 GMT",
63               (new Date(2014, 2, 30, 3, 59)).toUTCString());
64  assertEquals("Sun Mar 30 2014 04:00:00 GMT+0200 (CEST)",
65               (new Date(2014, 2, 30, 4, 0)).toString());
66  assertEquals("Sun, 30 Mar 2014 02:00:00 GMT",
67               (new Date(2014, 2, 30, 4, 0)).toUTCString());
68  assertEquals("Sat Oct 25 2014 22:59:00 GMT+0200 (CEST)",
69               (new Date(2014, 9, 25, 22, 59)).toString());
70  assertEquals("Sat, 25 Oct 2014 20:59:00 GMT",
71               (new Date(2014, 9, 25, 22, 59)).toUTCString());
72  assertEquals("Sat Oct 25 2014 23:00:00 GMT+0200 (CEST)",
73               (new Date(2014, 9, 25, 23, 0)).toString());
74  assertEquals("Sat, 25 Oct 2014 21:00:00 GMT",
75               (new Date(2014, 9, 25, 23, 0)).toUTCString());
76  assertEquals("Sat Oct 25 2014 23:59:00 GMT+0200 (CEST)",
77               (new Date(2014, 9, 25, 23, 59)).toString());
78  assertEquals("Sat, 25 Oct 2014 21:59:00 GMT",
79               (new Date(2014, 9, 25, 23, 59)).toUTCString());
80  assertEquals("Sun Oct 26 2014 00:00:00 GMT+0200 (CEST)",
81               (new Date(2014, 9, 26, 0, 0)).toString());
82  assertEquals("Sat, 25 Oct 2014 22:00:00 GMT",
83               (new Date(2014, 9, 26, 0, 0)).toUTCString());
84  assertEquals("Sun Oct 26 2014 00:59:00 GMT+0200 (CEST)",
85               (new Date(2014, 9, 26, 0, 59)).toString());
86  assertEquals("Sat, 25 Oct 2014 22:59:00 GMT",
87               (new Date(2014, 9, 26, 0, 59)).toUTCString());
88  assertEquals("Sun Oct 26 2014 01:00:00 GMT+0200 (CEST)",
89               (new Date(2014, 9, 26, 1, 0)).toString());
90  assertEquals("Sat, 25 Oct 2014 23:00:00 GMT",
91               (new Date(2014, 9, 26, 1, 0)).toUTCString());
92  assertEquals("Sun Oct 26 2014 01:59:00 GMT+0200 (CEST)",
93               (new Date(2014, 9, 26, 1, 59)).toString());
94  assertEquals("Sat, 25 Oct 2014 23:59:00 GMT",
95               (new Date(2014, 9, 26, 1, 59)).toUTCString());
96  assertEquals("Sun Oct 26 2014 02:00:00 GMT+0200 (CEST)",
97               (new Date(2014, 9, 26, 2, 0)).toString());
98  assertEquals("Sun, 26 Oct 2014 00:00:00 GMT",
99               (new Date(2014, 9, 26, 2, 0)).toUTCString());
100  assertEquals("Sun Oct 26 2014 02:59:00 GMT+0200 (CEST)",
101               (new Date(2014, 9, 26, 2, 59)).toString());
102  assertEquals("Sun, 26 Oct 2014 00:59:00 GMT",
103               (new Date(2014, 9, 26, 2, 59)).toUTCString());
104  assertEquals("Sun Oct 26 2014 03:00:00 GMT+0100 (CET)",
105               (new Date(2014, 9, 26, 3, 0)).toString());
106  assertEquals("Sun, 26 Oct 2014 02:00:00 GMT",
107               (new Date(2014, 9, 26, 3, 0)).toUTCString());
108  assertEquals("Sun Oct 26 2014 03:59:00 GMT+0100 (CET)",
109               (new Date(2014, 9, 26, 3, 59)).toString());
110  assertEquals("Sun, 26 Oct 2014 02:59:00 GMT",
111               (new Date(2014, 9, 26, 3, 59)).toUTCString());
112  assertEquals("Sun Oct 26 2014 04:00:00 GMT+0100 (CET)",
113               (new Date(2014, 9, 26, 4, 0)).toString());
114  assertEquals("Sun, 26 Oct 2014 03:00:00 GMT",
115               (new Date(2014, 9, 26, 4, 0)).toUTCString());
116}
117
118if (timezone("BRT")) {
119  assertEquals("Sat Oct 18 2014 22:59:00 GMT-0300 (BRT)",
120               (new Date(2014, 9, 18, 22, 59)).toString());
121  assertEquals("Sun, 19 Oct 2014 01:59:00 GMT",
122               (new Date(2014, 9, 18, 22, 59)).toUTCString());
123  assertEquals("Sat Oct 18 2014 23:00:00 GMT-0300 (BRT)",
124               (new Date(2014, 9, 18, 23, 0)).toString());
125  assertEquals("Sun, 19 Oct 2014 02:00:00 GMT",
126               (new Date(2014, 9, 18, 23, 0)).toUTCString());
127  assertEquals("Sat Oct 18 2014 23:59:00 GMT-0300 (BRT)",
128               (new Date(2014, 9, 18, 23, 59)).toString());
129  assertEquals("Sun, 19 Oct 2014 02:59:00 GMT",
130               (new Date(2014, 9, 18, 23, 59)).toUTCString());
131  assertEquals("Sun Oct 19 2014 01:00:00 GMT-0200 (BRST)",
132               (new Date(2014, 9, 19, 0, 0)).toString());
133  assertEquals("Sun, 19 Oct 2014 03:00:00 GMT",
134               (new Date(2014, 9, 19, 0, 0)).toUTCString());
135  assertEquals("Sun Oct 19 2014 01:59:00 GMT-0200 (BRST)",
136               (new Date(2014, 9, 19, 0, 59)).toString());
137  assertEquals("Sun, 19 Oct 2014 03:59:00 GMT",
138               (new Date(2014, 9, 19, 0, 59)).toUTCString());
139  assertEquals("Sun Oct 19 2014 01:00:00 GMT-0200 (BRST)",
140               (new Date(2014, 9, 19, 1, 0)).toString());
141  assertEquals("Sun, 19 Oct 2014 03:00:00 GMT",
142               (new Date(2014, 9, 19, 1, 0)).toUTCString());
143  assertEquals("Sun Oct 19 2014 01:59:00 GMT-0200 (BRST)",
144               (new Date(2014, 9, 19, 1, 59)).toString());
145  assertEquals("Sun, 19 Oct 2014 03:59:00 GMT",
146               (new Date(2014, 9, 19, 1, 59)).toUTCString());
147  assertEquals("Sun Oct 19 2014 02:00:00 GMT-0200 (BRST)",
148               (new Date(2014, 9, 19, 2, 0)).toString());
149  assertEquals("Sun, 19 Oct 2014 04:00:00 GMT",
150               (new Date(2014, 9, 19, 2, 0)).toUTCString());
151  assertEquals("Sun Oct 19 2014 02:59:00 GMT-0200 (BRST)",
152               (new Date(2014, 9, 19, 2, 59)).toString());
153  assertEquals("Sun, 19 Oct 2014 04:59:00 GMT",
154               (new Date(2014, 9, 19, 2, 59)).toUTCString());
155  assertEquals("Sun Oct 19 2014 03:00:00 GMT-0200 (BRST)",
156               (new Date(2014, 9, 19, 3, 0)).toString());
157  assertEquals("Sun, 19 Oct 2014 05:00:00 GMT",
158               (new Date(2014, 9, 19, 3, 0)).toUTCString());
159  assertEquals("Sun Oct 19 2014 03:59:00 GMT-0200 (BRST)",
160               (new Date(2014, 9, 19, 3, 59)).toString());
161  assertEquals("Sun, 19 Oct 2014 05:59:00 GMT",
162               (new Date(2014, 9, 19, 3, 59)).toUTCString());
163  assertEquals("Sun Oct 19 2014 04:00:00 GMT-0200 (BRST)",
164               (new Date(2014, 9, 19, 4, 0)).toString());
165  assertEquals("Sun, 19 Oct 2014 06:00:00 GMT",
166               (new Date(2014, 9, 19, 4, 0)).toUTCString());
167  assertEquals("Sat Feb 15 2014 22:59:00 GMT-0200 (BRST)",
168               (new Date(2014, 1, 15, 22, 59)).toString());
169  assertEquals("Sun, 16 Feb 2014 00:59:00 GMT",
170               (new Date(2014, 1, 15, 22, 59)).toUTCString());
171  assertEquals("Sat Feb 15 2014 23:00:00 GMT-0200 (BRST)",
172               (new Date(2014, 1, 15, 23, 0)).toString());
173  assertEquals("Sun, 16 Feb 2014 01:00:00 GMT",
174               (new Date(2014, 1, 15, 23, 0)).toUTCString());
175  assertEquals("Sat Feb 15 2014 23:59:00 GMT-0200 (BRST)",
176               (new Date(2014, 1, 15, 23, 59)).toString());
177  assertEquals("Sun, 16 Feb 2014 01:59:00 GMT",
178               (new Date(2014, 1, 15, 23, 59)).toUTCString());
179  assertEquals("Sun Feb 16 2014 00:00:00 GMT-0300 (BRT)",
180               (new Date(2014, 1, 16, 0, 0)).toString());
181  assertEquals("Sun, 16 Feb 2014 03:00:00 GMT",
182               (new Date(2014, 1, 16, 0, 0)).toUTCString());
183  assertEquals("Sun Feb 16 2014 00:59:00 GMT-0300 (BRT)",
184               (new Date(2014, 1, 16, 0, 59)).toString());
185  assertEquals("Sun, 16 Feb 2014 03:59:00 GMT",
186               (new Date(2014, 1, 16, 0, 59)).toUTCString());
187  assertEquals("Sun Feb 16 2014 01:00:00 GMT-0300 (BRT)",
188               (new Date(2014, 1, 16, 1, 0)).toString());
189  assertEquals("Sun, 16 Feb 2014 04:00:00 GMT",
190               (new Date(2014, 1, 16, 1, 0)).toUTCString());
191  assertEquals("Sun Feb 16 2014 01:59:00 GMT-0300 (BRT)",
192               (new Date(2014, 1, 16, 1, 59)).toString());
193  assertEquals("Sun, 16 Feb 2014 04:59:00 GMT",
194               (new Date(2014, 1, 16, 1, 59)).toUTCString());
195  assertEquals("Sun Feb 16 2014 02:00:00 GMT-0300 (BRT)",
196               (new Date(2014, 1, 16, 2, 0)).toString());
197  assertEquals("Sun, 16 Feb 2014 05:00:00 GMT",
198               (new Date(2014, 1, 16, 2, 0)).toUTCString());
199  assertEquals("Sun Feb 16 2014 02:59:00 GMT-0300 (BRT)",
200               (new Date(2014, 1, 16, 2, 59)).toString());
201  assertEquals("Sun, 16 Feb 2014 05:59:00 GMT",
202               (new Date(2014, 1, 16, 2, 59)).toUTCString());
203  assertEquals("Sun Feb 16 2014 03:00:00 GMT-0300 (BRT)",
204               (new Date(2014, 1, 16, 3, 0)).toString());
205  assertEquals("Sun, 16 Feb 2014 06:00:00 GMT",
206               (new Date(2014, 1, 16, 3, 0)).toUTCString());
207  assertEquals("Sun Feb 16 2014 03:59:00 GMT-0300 (BRT)",
208               (new Date(2014, 1, 16, 3, 59)).toString());
209  assertEquals("Sun, 16 Feb 2014 06:59:00 GMT",
210               (new Date(2014, 1, 16, 3, 59)).toUTCString());
211  assertEquals("Sun Feb 16 2014 04:00:00 GMT-0300 (BRT)",
212               (new Date(2014, 1, 16, 4, 0)).toString());
213  assertEquals("Sun, 16 Feb 2014 07:00:00 GMT",
214               (new Date(2014, 1, 16, 4, 0)).toUTCString());
215}
216
217if (timezone("PST")) {
218  assertEquals("Sat Mar 08 2014 22:59:00 GMT-0800 (PST)",
219               (new Date(2014, 2, 8, 22, 59)).toString());
220  assertEquals("Sun, 09 Mar 2014 06:59:00 GMT",
221               (new Date(2014, 2, 8, 22, 59)).toUTCString());
222  assertEquals("Sat Mar 08 2014 23:00:00 GMT-0800 (PST)",
223               (new Date(2014, 2, 8, 23, 0)).toString());
224  assertEquals("Sun, 09 Mar 2014 07:00:00 GMT",
225               (new Date(2014, 2, 8, 23, 0)).toUTCString());
226  assertEquals("Sat Mar 08 2014 23:59:00 GMT-0800 (PST)",
227               (new Date(2014, 2, 8, 23, 59)).toString());
228  assertEquals("Sun, 09 Mar 2014 07:59:00 GMT",
229               (new Date(2014, 2, 8, 23, 59)).toUTCString());
230  assertEquals("Sun Mar 09 2014 00:00:00 GMT-0800 (PST)",
231               (new Date(2014, 2, 9, 0, 0)).toString());
232  assertEquals("Sun, 09 Mar 2014 08:00:00 GMT",
233               (new Date(2014, 2, 9, 0, 0)).toUTCString());
234  assertEquals("Sun Mar 09 2014 00:59:00 GMT-0800 (PST)",
235               (new Date(2014, 2, 9, 0, 59)).toString());
236  assertEquals("Sun, 09 Mar 2014 08:59:00 GMT",
237               (new Date(2014, 2, 9, 0, 59)).toUTCString());
238  assertEquals("Sun Mar 09 2014 01:00:00 GMT-0800 (PST)",
239               (new Date(2014, 2, 9, 1, 0)).toString());
240  assertEquals("Sun, 09 Mar 2014 09:00:00 GMT",
241               (new Date(2014, 2, 9, 1, 0)).toUTCString());
242  assertEquals("Sun Mar 09 2014 01:59:00 GMT-0800 (PST)",
243               (new Date(2014, 2, 9, 1, 59)).toString());
244  assertEquals("Sun, 09 Mar 2014 09:59:00 GMT",
245               (new Date(2014, 2, 9, 1, 59)).toUTCString());
246  assertEquals("Sun Mar 09 2014 03:00:00 GMT-0700 (PDT)",
247               (new Date(2014, 2, 9, 2, 0)).toString());
248  assertEquals("Sun, 09 Mar 2014 10:00:00 GMT",
249               (new Date(2014, 2, 9, 2, 0)).toUTCString());
250  assertEquals("Sun Mar 09 2014 03:59:00 GMT-0700 (PDT)",
251               (new Date(2014, 2, 9, 2, 59)).toString());
252  assertEquals("Sun, 09 Mar 2014 10:59:00 GMT",
253               (new Date(2014, 2, 9, 2, 59)).toUTCString());
254  assertEquals("Sun Mar 09 2014 03:00:00 GMT-0700 (PDT)",
255               (new Date(2014, 2, 9, 3, 0)).toString());
256  assertEquals("Sun, 09 Mar 2014 10:00:00 GMT",
257               (new Date(2014, 2, 9, 3, 0)).toUTCString());
258  assertEquals("Sun Mar 09 2014 03:59:00 GMT-0700 (PDT)",
259               (new Date(2014, 2, 9, 3, 59)).toString());
260  assertEquals("Sun, 09 Mar 2014 10:59:00 GMT",
261               (new Date(2014, 2, 9, 3, 59)).toUTCString());
262  assertEquals("Sun Mar 09 2014 04:00:00 GMT-0700 (PDT)",
263               (new Date(2014, 2, 9, 4, 0)).toString());
264  assertEquals("Sun, 09 Mar 2014 11:00:00 GMT",
265               (new Date(2014, 2, 9, 4, 0)).toUTCString());
266  assertEquals("Sat Nov 01 2014 22:59:00 GMT-0700 (PDT)",
267               (new Date(2014, 10, 1, 22, 59)).toString());
268  assertEquals("Sun, 02 Nov 2014 05:59:00 GMT",
269               (new Date(2014, 10, 1, 22, 59)).toUTCString());
270  assertEquals("Sat Nov 01 2014 23:00:00 GMT-0700 (PDT)",
271               (new Date(2014, 10, 1, 23, 0)).toString());
272  assertEquals("Sun, 02 Nov 2014 06:00:00 GMT",
273               (new Date(2014, 10, 1, 23, 0)).toUTCString());
274  assertEquals("Sat Nov 01 2014 23:59:00 GMT-0700 (PDT)",
275               (new Date(2014, 10, 1, 23, 59)).toString());
276  assertEquals("Sun, 02 Nov 2014 06:59:00 GMT",
277               (new Date(2014, 10, 1, 23, 59)).toUTCString());
278  assertEquals("Sun Nov 02 2014 00:00:00 GMT-0700 (PDT)",
279               (new Date(2014, 10, 2, 0, 0)).toString());
280  assertEquals("Sun, 02 Nov 2014 07:00:00 GMT",
281               (new Date(2014, 10, 2, 0, 0)).toUTCString());
282  assertEquals("Sun Nov 02 2014 00:59:00 GMT-0700 (PDT)",
283               (new Date(2014, 10, 2, 0, 59)).toString());
284  assertEquals("Sun, 02 Nov 2014 07:59:00 GMT",
285               (new Date(2014, 10, 2, 0, 59)).toUTCString());
286  assertEquals("Sun Nov 02 2014 01:00:00 GMT-0700 (PDT)",
287               (new Date(2014, 10, 2, 1, 0)).toString());
288  assertEquals("Sun, 02 Nov 2014 08:00:00 GMT",
289               (new Date(2014, 10, 2, 1, 0)).toUTCString());
290  assertEquals("Sun Nov 02 2014 01:59:00 GMT-0700 (PDT)",
291               (new Date(2014, 10, 2, 1, 59)).toString());
292  assertEquals("Sun, 02 Nov 2014 08:59:00 GMT",
293               (new Date(2014, 10, 2, 1, 59)).toUTCString());
294  assertEquals("Sun Nov 02 2014 02:00:00 GMT-0800 (PST)",
295               (new Date(2014, 10, 2, 2, 0)).toString());
296  assertEquals("Sun, 02 Nov 2014 10:00:00 GMT",
297               (new Date(2014, 10, 2, 2, 0)).toUTCString());
298  assertEquals("Sun Nov 02 2014 02:59:00 GMT-0800 (PST)",
299               (new Date(2014, 10, 2, 2, 59)).toString());
300  assertEquals("Sun, 02 Nov 2014 10:59:00 GMT",
301               (new Date(2014, 10, 2, 2, 59)).toUTCString());
302  assertEquals("Sun Nov 02 2014 03:00:00 GMT-0800 (PST)",
303               (new Date(2014, 10, 2, 3, 0)).toString());
304  assertEquals("Sun, 02 Nov 2014 11:00:00 GMT",
305               (new Date(2014, 10, 2, 3, 0)).toUTCString());
306  assertEquals("Sun Nov 02 2014 03:59:00 GMT-0800 (PST)",
307               (new Date(2014, 10, 2, 3, 59)).toString());
308  assertEquals("Sun, 02 Nov 2014 11:59:00 GMT",
309               (new Date(2014, 10, 2, 3, 59)).toUTCString());
310  assertEquals("Sun Nov 02 2014 04:00:00 GMT-0800 (PST)",
311               (new Date(2014, 10, 2, 4, 0)).toString());
312  assertEquals("Sun, 02 Nov 2014 12:00:00 GMT",
313               (new Date(2014, 10, 2, 4, 0)).toUTCString());
314}
315