1 /* Digital Mars DMDScript source code.
2  * Copyright (c) 2000-2002 by Chromium Communications
3  * D version Copyright (c) 2004-2010 by Digital Mars
4  * Distributed under the Boost Software License, Version 1.0.
5  * (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  * written by Walter Bright
7  * http://www.digitalmars.com
8  *
9  * D2 port by Dmitry Olshansky 
10  *
11  * DMDScript is implemented in the D Programming Language,
12  * http://www.digitalmars.com/d/
13  *
14  * For a C++ implementation of DMDScript, including COM support, see
15  * http://www.digitalmars.com/dscript/cppscript.html
16  */
17 
18 module dmdscript.ddate;
19 
20 import undead.date;
21 import std.math;
22 
23 debug
24 {
25     import std.stdio;
26 }
27 
28 import dmdscript.script;
29 import dmdscript.dobject;
30 import dmdscript.value;
31 import dmdscript.threadcontext;
32 import dmdscript.dfunction;
33 import dmdscript.dnative;
34 import dmdscript.property;
35 import dmdscript.text;
36 import dmdscript.errmsgs;
37 
38 
39 version = DATETOSTRING;                 // use DateToString
40 
41 enum TIMEFORMAT
42 {
43     String,
44     DateString,
45     TimeString,
46     LocaleString,
47     LocaleDateString,
48     LocaleTimeString,
49     UTCString,
50 }
51 
52 d_time parseDateString(CallContext *cc, string s)
53 {
54     return parse(s);
55 }
56 
57 string dateToString(CallContext *cc, d_time t, TIMEFORMAT tf)
58 {
59     string p;
60 
61     if(t == d_time_nan)
62         p = "Invalid Date";
63     else
64     {
65         switch(tf)
66         {
67         case TIMEFORMAT.String:
68             t = localTimetoUTC(t);
69             p = UTCtoString(t);
70             break;
71 
72         case TIMEFORMAT.DateString:
73             t = localTimetoUTC(t);
74             p = toDateString(t);
75             break;
76 
77         case TIMEFORMAT.TimeString:
78             t = localTimetoUTC(t);
79             p = toTimeString(t);
80             break;
81 
82         case TIMEFORMAT.LocaleString:
83             //p = toLocaleString(t);
84             p = UTCtoString(t);
85             break;
86 
87         case TIMEFORMAT.LocaleDateString:
88             //p = toLocaleDateString(t);
89             p = toDateString(t);
90             break;
91 
92         case TIMEFORMAT.LocaleTimeString:
93             //p = toLocaleTimeString(t);
94             p = toTimeString(t);
95             break;
96 
97         case TIMEFORMAT.UTCString:
98             p = toUTCString(t);
99             //p = toString(t);
100             break;
101 
102         default:
103             assert(0);
104         }
105     }
106     return p;
107 }
108 
109 
110 /* ===================== Ddate.constructor functions ==================== */
111 
112 void* Ddate_parse(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
113 {
114     // ECMA 15.9.4.2
115     string s;
116     d_time n;
117 
118     if(arglist.length == 0)
119         n = d_time_nan;
120     else
121     {
122         s = arglist[0].toString(cc);
123         n = parseDateString(cc, s);
124     }
125 
126     ret.putVtime(n);
127     return null;
128 }
129 
130 void* Ddate_UTC(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
131 {
132     // ECMA 15.9.4.3 - 15.9.4.10
133 
134     d_time n;
135 
136     d_time year;
137     d_time month = 0;
138     d_time date = 0;
139     d_time hours = 0;
140     d_time minutes = 0;
141     d_time seconds = 0;
142     d_time ms = 0;
143 
144     d_time day;
145     d_time time = 0;
146 
147     switch(arglist.length)
148     {
149     default:
150     case 7:
151         ms = arglist[6].toDtime(cc);
152         goto case;
153     case 6:
154         seconds = arglist[5].toDtime(cc);
155         goto case;
156     case 5:
157         minutes = arglist[4].toDtime(cc);
158         goto case;
159     case 4:
160         hours = arglist[3].toDtime(cc);
161         time = makeTime(hours, minutes, seconds, ms);
162         goto case;
163     case 3:
164         date = arglist[2].toDtime(cc);
165         goto case;
166     case 2:
167         month = arglist[1].toDtime(cc);
168         goto case;
169     case 1:
170         year = arglist[0].toDtime(cc);
171 
172         if(year != d_time_nan && year >= 0 && year <= 99)
173             year += 1900;
174         day = makeDay(year, month, date);
175         n = timeClip(makeDate(day, time));
176         break;
177 
178     case 0:
179         n = getUTCtime();
180         break;
181     }
182     ret.putVtime(n);
183     return null;
184 }
185 
186 /* ===================== Ddate_constructor ==================== */
187 
188 class DdateConstructor : Dfunction
189 {
190     this(CallContext* cc)
191     {
192         super(cc, 7, cc.tc.Dfunction_prototype);
193         name = "Date";
194 
195         static enum NativeFunctionData[] nfd =
196         [
197             { TEXT_parse, &Ddate_parse, 1 },
198             { TEXT_UTC, &Ddate_UTC, 7 },
199         ];
200 
201         DnativeFunction.initialize(this, cc, nfd, DontEnum);
202     }
203 
204     override void *Construct(CallContext *cc, Value *ret, Value[] arglist)
205     {
206         // ECMA 15.9.3
207         Dobject o;
208         d_time n;
209 
210         d_time year;
211         d_time month;
212         d_time date = 0;
213         d_time hours = 0;
214         d_time minutes = 0;
215         d_time seconds = 0;
216         d_time ms = 0;
217 
218         d_time day;
219         d_time time = 0;
220         //generate NaN check boilerplate code
221         static d_string breakOnNan(d_string var)
222         {
223             return "if(" ~ var ~ " == d_time_nan){
224 			n = d_time_nan;
225 			break;
226 		}";
227         }
228         //writefln("Ddate_constructor.Construct()");
229         switch(arglist.length)
230         {
231         default:
232         case 7:
233             ms = arglist[6].toDtime(cc);
234             mixin (breakOnNan("ms"));
235             goto case;
236         case 6:
237             seconds = arglist[5].toDtime(cc);
238             mixin (breakOnNan("seconds"));
239             goto case;
240         case 5:
241             minutes = arglist[4].toDtime(cc);
242             mixin (breakOnNan("minutes"));
243             goto case;
244         case 4:
245             hours = arglist[3].toDtime(cc);
246             mixin (breakOnNan("hours"));
247             time = makeTime(hours, minutes, seconds, ms);
248             goto case;
249         case 3:
250             date = arglist[2].toDtime(cc);
251             goto case;
252         case 2:
253             month = arglist[1].toDtime(cc);
254             year = arglist[0].toDtime(cc);
255 
256             if(year != d_time_nan && year >= 0 && year <= 99)
257                 year += 1900;
258             day = makeDay(year, month, date);
259             n = timeClip(localTimetoUTC(makeDate(day, time)));
260             break;
261 
262         case 1:
263             arglist[0].toPrimitive(cc, ret, null);
264             if(ret.getType() == TypeString)
265             {
266                 n = parseDateString(cc, ret..string);
267             }
268             else
269             {
270                 n = ret.toDtime(cc);
271                 n = timeClip(n);
272             }
273             break;
274 
275         case 0:
276             n = getUTCtime();
277             break;
278         }
279         //writefln("\tn = %s", n);
280         o = new Ddate(cc, n);
281         ret.putVobject(o);
282         return null;
283     }
284 
285     override void *Call(CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
286     {
287         // ECMA 15.9.2
288         // return string as if (new Date()).toString()
289         immutable(char)[] s;
290         d_time t;
291 
292         version(DATETOSTRING)
293         {
294             t = getUTCtime();
295             t = UTCtoLocalTime(t);
296             s = dateToString(cc, t, TIMEFORMAT.String);
297         }
298         else
299         {
300             t = time();
301             s = toString(t);
302         }
303         ret.putVstring(s);
304         return null;
305     }
306 }
307 
308 
309 /* ===================== Ddate.prototype functions =============== */
310 
311 void *checkdate(Value* ret, CallContext* cc, d_string name, Dobject othis)
312 {
313     ret.putVundefined();
314     ErrInfo errinfo;
315     return Dobject.RuntimeError(&errinfo, cc, errmsgtbl[ERR_FUNCTION_WANTS_DATE],
316                                 name, othis.classname);
317 }
318 
319 int getThisTime(Value* ret, Dobject othis, out d_time n)
320 {
321     d_number x;
322 
323     n = cast(d_time)othis.value.number;
324     ret.putVtime(n);
325     return (n == d_time_nan) ? 1 : 0;
326 }
327 
328 int getThisLocalTime(Value* ret, Dobject othis, out d_time n)
329 {
330     int isn = 1;
331 
332     n = cast(d_time)othis.value.number;
333     if(n != d_time_nan)
334     {
335         isn = 0;
336         n = UTCtoLocalTime(n);
337     }
338     ret.putVtime(n);
339     return isn;
340 }
341 
342 void* Ddate_prototype_toString(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
343 {
344     // ECMA 15.9.5.2
345     d_time n;
346     immutable(char)[] s;
347 
348     //writefln("Ddate_prototype_toString()");
349     if(!othis.isDdate())
350         return checkdate(ret, cc, TEXT_toString, othis);
351 
352     version(DATETOSTRING)
353     {
354         getThisLocalTime(ret, othis, n);
355         s = dateToString(cc, n, TIMEFORMAT.String);
356     }
357     else
358     {
359         getThisTime(ret, othis, n);
360         s = toString(n);
361     }
362     ret.putVstring(s);
363     return null;
364 }
365 
366 void* Ddate_prototype_toDateString(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
367 {
368     // ECMA 15.9.5.3
369     d_time n;
370     immutable(char)[] s;
371 
372     if(!othis.isDdate())
373         return checkdate(ret, cc, TEXT_toDateString, othis);
374 
375     version(DATETOSTRING)
376     {
377         getThisLocalTime(ret, othis, n);
378         s = dateToString(cc, n, TIMEFORMAT.DateString);
379     }
380     else
381     {
382         getThisTime(ret, othis, n);
383         s = toDateString(n);
384     }
385     ret.putVstring(s);
386     return null;
387 }
388 
389 void* Ddate_prototype_toTimeString(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
390 {
391     // ECMA 15.9.5.4
392     d_time n;
393     immutable(char)[] s;
394 
395     if(!othis.isDdate())
396         return checkdate(ret, cc, TEXT_toTimeString, othis);
397 
398     version(DATETOSTRING)
399     {
400         getThisLocalTime(ret, othis, n);
401         s = dateToString(cc, n, TIMEFORMAT.TimeString);
402     }
403     else
404     {
405         getThisTime(ret, othis, n);
406         s = toTimeString(n);
407     }
408     //s = toTimeString(n);
409     ret.putVstring(s);
410     return null;
411 }
412 
413 void* Ddate_prototype_valueOf(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
414 {
415     // ECMA 15.9.5.3
416     d_time n;
417 
418     if(!othis.isDdate())
419         return checkdate(ret, cc, TEXT_valueOf, othis);
420     getThisTime(ret, othis, n);
421     return null;
422 }
423 
424 void* Ddate_prototype_getTime(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
425 {
426     // ECMA 15.9.5.4
427     d_time n;
428 
429     if(!othis.isDdate())
430         return checkdate(ret, cc, TEXT_getTime, othis);
431     getThisTime(ret, othis, n);
432     return null;
433 }
434 
435 void* Ddate_prototype_getYear(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
436 {
437     // ECMA 15.9.5.5
438     d_time n;
439 
440     if(!othis.isDdate())
441         return checkdate(ret, cc, TEXT_getYear, othis);
442 
443     if(getThisLocalTime(ret, othis, n) == 0)
444     {
445         n = yearFromTime(n);
446         if(n != d_time_nan)
447         {
448             n -= 1900;
449             version(all)  // emulate jscript bug
450             {
451                 if(n < 0 || n >= 100)
452                     n += 1900;
453             }
454         }
455         ret.putVtime(n);
456     }
457     return null;
458 }
459 
460 void* Ddate_prototype_getFullYear(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
461 {
462     // ECMA 15.9.5.6
463     d_time n;
464 
465     if(!othis.isDdate())
466         return checkdate(ret, cc, TEXT_getFullYear, othis);
467 
468     if(getThisLocalTime(ret, othis, n) == 0)
469     {
470         n = yearFromTime(n);
471         ret.putVtime(n);
472     }
473     return null;
474 }
475 
476 void* Ddate_prototype_getUTCFullYear(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
477 {
478     // ECMA 15.9.5.7
479     d_time n;
480 
481     if(!othis.isDdate())
482         return checkdate(ret, cc, TEXT_getUTCFullYear, othis);
483     if(getThisTime(ret, othis, n) == 0)
484     {
485         n = yearFromTime(n);
486         ret.putVtime(n);
487     }
488     return null;
489 }
490 
491 void* Ddate_prototype_getMonth(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
492 {
493     // ECMA 15.9.5.8
494     d_time n;
495 
496     if(!othis.isDdate())
497         return checkdate(ret, cc, TEXT_getMonth, othis);
498 
499     if(getThisLocalTime(ret, othis, n) == 0)
500     {
501         n = monthFromTime(n);
502         ret.putVtime(n);
503     }
504     return null;
505 }
506 
507 void* Ddate_prototype_getUTCMonth(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
508 {
509     // ECMA 15.9.5.9
510     d_time n;
511 
512     if(!othis.isDdate())
513         return checkdate(ret, cc, TEXT_getUTCMonth, othis);
514 
515     if(getThisTime(ret, othis, n) == 0)
516     {
517         n = monthFromTime(n);
518         ret.putVtime(n);
519     }
520     return null;
521 }
522 
523 void* Ddate_prototype_getDate(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
524 {
525     // ECMA 15.9.5.10
526     d_time n;
527 
528     if(!othis.isDdate())
529         return checkdate(ret, cc, TEXT_getDate, othis);
530 
531     if(getThisLocalTime(ret, othis, n) == 0)
532     {
533         //printf("LocalTime = %.16g\n", n);
534         //printf("DaylightSavingTA(n) = %d\n", daylightSavingTA(n));
535         n = dateFromTime(n);
536         ret.putVtime(n);
537     }
538     return null;
539 }
540 
541 void* Ddate_prototype_getUTCDate(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
542 {
543     // ECMA 15.9.5.11
544     d_time n;
545 
546     if(!othis.isDdate())
547         return checkdate(ret, cc, TEXT_getUTCDate, othis);
548 
549     if(getThisTime(ret, othis, n) == 0)
550     {
551         n = dateFromTime(n);
552         ret.putVtime(n);
553     }
554     return null;
555 }
556 
557 void* Ddate_prototype_getDay(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
558 {
559     // ECMA 15.9.5.12
560     d_time n;
561 
562     if(!othis.isDdate())
563         return checkdate(ret, cc, TEXT_getDay, othis);
564 
565     if(getThisLocalTime(ret, othis, n) == 0)
566     {
567         n = weekDay(n);
568         ret.putVtime(n);
569     }
570     return null;
571 }
572 
573 void* Ddate_prototype_getUTCDay(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
574 {
575     // ECMA 15.9.5.13
576     d_time n;
577 
578     if(!othis.isDdate())
579         return checkdate(ret, cc, TEXT_getUTCDay, othis);
580 
581     if(getThisTime(ret, othis, n) == 0)
582     {
583         n = weekDay(n);
584         ret.putVtime(n);
585     }
586     return null;
587 }
588 
589 void* Ddate_prototype_getHours(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
590 {
591     // ECMA 15.9.5.14
592     d_time n;
593 
594     if(!othis.isDdate())
595         return checkdate(ret, cc, TEXT_getHours, othis);
596 
597     if(getThisLocalTime(ret, othis, n) == 0)
598     {
599         n = hourFromTime(n);
600         ret.putVtime(n);
601     }
602     return null;
603 }
604 
605 void* Ddate_prototype_getUTCHours(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
606 {
607     // ECMA 15.9.5.15
608     d_time n;
609 
610     if(!othis.isDdate())
611         return checkdate(ret, cc, TEXT_getUTCHours, othis);
612 
613     if(getThisTime(ret, othis, n) == 0)
614     {
615         n = hourFromTime(n);
616         ret.putVtime(n);
617     }
618     return null;
619 }
620 
621 void* Ddate_prototype_getMinutes(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
622 {
623     // ECMA 15.9.5.16
624     d_time n;
625 
626     if(!othis.isDdate())
627         return checkdate(ret, cc, TEXT_getMinutes, othis);
628 
629     if(getThisLocalTime(ret, othis, n) == 0)
630     {
631         n = minFromTime(n);
632         ret.putVtime(n);
633     }
634     return null;
635 }
636 
637 void* Ddate_prototype_getUTCMinutes(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
638 {
639     // ECMA 15.9.5.17
640     d_time n;
641 
642     if(!othis.isDdate())
643         return checkdate(ret, cc, TEXT_getUTCMinutes, othis);
644 
645     if(getThisTime(ret, othis, n) == 0)
646     {
647         n = minFromTime(n);
648         ret.putVtime(n);
649     }
650     return null;
651 }
652 
653 void* Ddate_prototype_getSeconds(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
654 {
655     // ECMA 15.9.5.18
656     d_time n;
657 
658     if(!othis.isDdate())
659         return checkdate(ret, cc, TEXT_getSeconds, othis);
660 
661     if(getThisLocalTime(ret, othis, n) == 0)
662     {
663         n = secFromTime(n);
664         ret.putVtime(n);
665     }
666     return null;
667 }
668 
669 void* Ddate_prototype_getUTCSeconds(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
670 {
671     // ECMA 15.9.5.19
672     d_time n;
673 
674     if(!othis.isDdate())
675         return checkdate(ret, cc, TEXT_getUTCSeconds, othis);
676 
677     if(getThisTime(ret, othis, n) == 0)
678     {
679         n = secFromTime(n);
680         ret.putVtime(n);
681     }
682     return null;
683 }
684 
685 void* Ddate_prototype_getMilliseconds(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
686 {
687     // ECMA 15.9.5.20
688     d_time n;
689 
690     if(!othis.isDdate())
691         return checkdate(ret, cc, TEXT_getMilliseconds, othis);
692 
693     if(getThisLocalTime(ret, othis, n) == 0)
694     {
695         n = msFromTime(n);
696         ret.putVtime(n);
697     }
698     return null;
699 }
700 
701 void* Ddate_prototype_getUTCMilliseconds(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
702 {
703     // ECMA 15.9.5.21
704     d_time n;
705 
706     if(!othis.isDdate())
707         return checkdate(ret, cc, TEXT_getUTCMilliseconds, othis);
708 
709     if(getThisTime(ret, othis, n) == 0)
710     {
711         n = msFromTime(n);
712         ret.putVtime(n);
713     }
714     return null;
715 }
716 
717 void* Ddate_prototype_getTimezoneOffset(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
718 {
719     // ECMA 15.9.5.22
720     d_time n;
721 
722     if(!othis.isDdate())
723         return checkdate(ret, cc, TEXT_getTimezoneOffset, othis);
724 
725     if(getThisTime(ret, othis, n) == 0)
726     {
727         n = (n - UTCtoLocalTime(n)) / (60 * 1000);
728         ret.putVtime(n);
729     }
730     return null;
731 }
732 
733 void* Ddate_prototype_setTime(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
734 {
735     // ECMA 15.9.5.23
736     d_time n;
737 
738     if(!othis.isDdate())
739         return checkdate(ret, cc, TEXT_setTime, othis);
740 
741     if(!arglist.length)
742         n = d_time_nan;
743     else
744         n = arglist[0].toDtime(cc);
745     n = timeClip(n);
746     othis.value.putVtime(n);
747     ret.putVtime(n);
748     return null;
749 }
750 
751 void* Ddate_prototype_setMilliseconds(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
752 {
753     // ECMA 15.9.5.24
754 
755     d_time ms;
756     d_time t;
757     d_time time;
758     d_time n;
759 
760     if(!othis.isDdate())
761         return checkdate(ret, cc, TEXT_setMilliseconds, othis);
762 
763     if(getThisLocalTime(ret, othis, t) == 0)
764     {
765         if(!arglist.length)
766             ms = d_time_nan;
767         else
768             ms = arglist[0].toDtime(cc);
769         time = makeTime(hourFromTime(t), minFromTime(t), secFromTime(t), ms);
770         n = timeClip(localTimetoUTC(makeDate(day(t), time)));
771         othis.value.putVtime(n);
772         ret.putVtime(n);
773     }
774     return null;
775 }
776 
777 void* Ddate_prototype_setUTCMilliseconds(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
778 {
779     // ECMA 15.9.5.25
780     d_time ms;
781     d_time t;
782     d_time time;
783     d_time n;
784 
785     if(!othis.isDdate())
786         return checkdate(ret, cc, TEXT_setUTCMilliseconds, othis);
787 
788     if(getThisTime(ret, othis, t) == 0)
789     {
790         if(!arglist.length)
791             ms = d_time_nan;
792         else
793             ms = arglist[0].toDtime(cc);
794         time = makeTime(hourFromTime(t), minFromTime(t), secFromTime(t), ms);
795         n = timeClip(makeDate(day(t), time));
796         othis.value.putVtime(n);
797         ret.putVtime(n);
798     }
799     return null;
800 }
801 
802 void* Ddate_prototype_setSeconds(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
803 {
804     // ECMA 15.9.5.26
805     d_time ms;
806     d_time seconds;
807     d_time t;
808     d_time time;
809     d_time n;
810 
811     if(!othis.isDdate())
812         return checkdate(ret, cc, TEXT_setSeconds, othis);
813 
814     if(getThisLocalTime(ret, othis, t) == 0)
815     {
816         switch(arglist.length)
817         {
818         default:
819         case 2:
820             ms = arglist[1].toDtime(cc);
821             seconds = arglist[0].toDtime(cc);
822             break;
823 
824         case 1:
825             ms = msFromTime(t);
826             seconds = arglist[0].toDtime(cc);
827             break;
828 
829         case 0:
830             ms = msFromTime(t);
831             seconds = d_time_nan;
832             break;
833         }
834         time = makeTime(hourFromTime(t), minFromTime(t), seconds, ms);
835         n = timeClip(localTimetoUTC(makeDate(day(t), time)));
836         othis.value.putVtime(n);
837         ret.putVtime(n);
838     }
839     return null;
840 }
841 
842 void* Ddate_prototype_setUTCSeconds(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
843 {
844     // ECMA 15.9.5.27
845     d_time ms;
846     d_time seconds;
847     d_time t;
848     d_time time;
849     d_time n;
850 
851     if(!othis.isDdate())
852         return checkdate(ret, cc, TEXT_setUTCSeconds, othis);
853 
854     if(getThisTime(ret, othis, t) == 0)
855     {
856         switch(arglist.length)
857         {
858         default:
859         case 2:
860             ms = arglist[1].toDtime(cc);
861             seconds = arglist[0].toDtime(cc);
862             break;
863 
864         case 1:
865             ms = msFromTime(t);
866             seconds = arglist[0].toDtime(cc);
867             break;
868 
869         case 0:
870             ms = msFromTime(t);
871             seconds = d_time_nan;
872             break;
873         }
874         time = makeTime(hourFromTime(t), minFromTime(t), seconds, ms);
875         n = timeClip(makeDate(day(t), time));
876         othis.value.putVtime(n);
877         ret.putVtime(n);
878     }
879     return null;
880 }
881 
882 void* Ddate_prototype_setMinutes(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
883 {
884     // ECMA 15.9.5.28
885     d_time ms;
886     d_time seconds;
887     d_time minutes;
888     d_time t;
889     d_time time;
890     d_time n;
891 
892     if(!othis.isDdate())
893         return checkdate(ret, cc, TEXT_setMinutes, othis);
894 
895     if(getThisLocalTime(ret, othis, t) == 0)
896     {
897         switch(arglist.length)
898         {
899         default:
900         case 3:
901             ms = arglist[2].toDtime(cc);
902             seconds = arglist[1].toDtime(cc);
903             minutes = arglist[0].toDtime(cc);
904             break;
905 
906         case 2:
907             ms = msFromTime(t);
908             seconds = arglist[1].toDtime(cc);
909             minutes = arglist[0].toDtime(cc);
910             break;
911 
912         case 1:
913             ms = msFromTime(t);
914             seconds = secFromTime(t);
915             minutes = arglist[0].toDtime(cc);
916             break;
917 
918         case 0:
919             ms = msFromTime(t);
920             seconds = secFromTime(t);
921             minutes = d_time_nan;
922             break;
923         }
924         time = makeTime(hourFromTime(t), minutes, seconds, ms);
925         n = timeClip(localTimetoUTC(makeDate(day(t), time)));
926         othis.value.putVtime(n);
927         ret.putVtime(n);
928     }
929     return null;
930 }
931 
932 void* Ddate_prototype_setUTCMinutes(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
933 {
934     // ECMA 15.9.5.29
935     d_time ms;
936     d_time seconds;
937     d_time minutes;
938     d_time t;
939     d_time time;
940     d_time n;
941 
942     if(!othis.isDdate())
943         return checkdate(ret, cc, TEXT_setUTCMinutes, othis);
944 
945     if(getThisTime(ret, othis, t) == 0)
946     {
947         switch(arglist.length)
948         {
949         default:
950         case 3:
951             ms = arglist[2].toDtime(cc);
952             seconds = arglist[1].toDtime(cc);
953             minutes = arglist[0].toDtime(cc);
954             break;
955 
956         case 2:
957             ms = msFromTime(t);
958             seconds = arglist[1].toDtime(cc);
959             minutes = arglist[0].toDtime(cc);
960             break;
961 
962         case 1:
963             ms = msFromTime(t);
964             seconds = secFromTime(t);
965             minutes = arglist[0].toDtime(cc);
966             break;
967 
968         case 0:
969             ms = msFromTime(t);
970             seconds = secFromTime(t);
971             minutes = d_time_nan;
972             break;
973         }
974         time = makeTime(hourFromTime(t), minutes, seconds, ms);
975         n = timeClip(makeDate(day(t), time));
976         othis.value.putVtime(n);
977         ret.putVtime(n);
978     }
979     return null;
980 }
981 
982 void* Ddate_prototype_setHours(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
983 {
984     // ECMA 15.9.5.30
985     d_time ms;
986     d_time seconds;
987     d_time minutes;
988     d_time hours;
989     d_time t;
990     d_time time;
991     d_time n;
992 
993     if(!othis.isDdate())
994         return checkdate(ret, cc, TEXT_setHours, othis);
995 
996     if(getThisLocalTime(ret, othis, t) == 0)
997     {
998         switch(arglist.length)
999         {
1000         default:
1001         case 4:
1002             ms = arglist[3].toDtime(cc);
1003             seconds = arglist[2].toDtime(cc);
1004             minutes = arglist[1].toDtime(cc);
1005             hours = arglist[0].toDtime(cc);
1006             break;
1007 
1008         case 3:
1009             ms = msFromTime(t);
1010             seconds = arglist[2].toDtime(cc);
1011             minutes = arglist[1].toDtime(cc);
1012             hours = arglist[0].toDtime(cc);
1013             break;
1014 
1015         case 2:
1016             ms = msFromTime(t);
1017             seconds = secFromTime(t);
1018             minutes = arglist[1].toDtime(cc);
1019             hours = arglist[0].toDtime(cc);
1020             break;
1021 
1022         case 1:
1023             ms = msFromTime(t);
1024             seconds = secFromTime(t);
1025             minutes = minFromTime(t);
1026             hours = arglist[0].toDtime(cc);
1027             break;
1028 
1029         case 0:
1030             ms = msFromTime(t);
1031             seconds = secFromTime(t);
1032             minutes = minFromTime(t);
1033             hours = d_time_nan;
1034             break;
1035         }
1036         time = makeTime(hours, minutes, seconds, ms);
1037         n = timeClip(localTimetoUTC(makeDate(day(t), time)));
1038         othis.value.putVtime(n);
1039         ret.putVtime(n);
1040     }
1041     return null;
1042 }
1043 
1044 void* Ddate_prototype_setUTCHours(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1045 {
1046     // ECMA 15.9.5.31
1047     d_time ms;
1048     d_time seconds;
1049     d_time minutes;
1050     d_time hours;
1051     d_time t;
1052     d_time time;
1053     d_time n;
1054 
1055     if(!othis.isDdate())
1056         return checkdate(ret, cc, TEXT_setUTCHours, othis);
1057 
1058     if(getThisTime(ret, othis, t) == 0)
1059     {
1060         switch(arglist.length)
1061         {
1062         default:
1063         case 4:
1064             ms = arglist[3].toDtime(cc);
1065             seconds = arglist[2].toDtime(cc);
1066             minutes = arglist[1].toDtime(cc);
1067             hours = arglist[0].toDtime(cc);
1068             break;
1069 
1070         case 3:
1071             ms = msFromTime(t);
1072             seconds = arglist[2].toDtime(cc);
1073             minutes = arglist[1].toDtime(cc);
1074             hours = arglist[0].toDtime(cc);
1075             break;
1076 
1077         case 2:
1078             ms = msFromTime(t);
1079             seconds = secFromTime(t);
1080             minutes = arglist[1].toDtime(cc);
1081             hours = arglist[0].toDtime(cc);
1082             break;
1083 
1084         case 1:
1085             ms = msFromTime(t);
1086             seconds = secFromTime(t);
1087             minutes = minFromTime(t);
1088             hours = arglist[0].toDtime(cc);
1089             break;
1090 
1091         case 0:
1092             ms = msFromTime(t);
1093             seconds = secFromTime(t);
1094             minutes = minFromTime(t);
1095             hours = d_time_nan;
1096             break;
1097         }
1098         time = makeTime(hours, minutes, seconds, ms);
1099         n = timeClip(makeDate(day(t), time));
1100         othis.value.putVtime(n);
1101         ret.putVtime(n);
1102     }
1103     return null;
1104 }
1105 
1106 void* Ddate_prototype_setDate(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1107 {
1108     // ECMA 15.9.5.32
1109     d_time date;
1110     d_time t;
1111     d_time day;
1112     d_time n;
1113 
1114     if(!othis.isDdate())
1115         return checkdate(ret, cc, TEXT_setDate, othis);
1116 
1117     if(getThisLocalTime(ret, othis, t) == 0)
1118     {
1119         if(!arglist.length)
1120             date = d_time_nan;
1121         else
1122             date = arglist[0].toDtime(cc);
1123         day = makeDay(yearFromTime(t), monthFromTime(t), date);
1124         n = timeClip(localTimetoUTC(makeDate(day, timeWithinDay(t))));
1125         othis.value.putVtime(n);
1126         ret.putVtime(n);
1127     }
1128     return null;
1129 }
1130 
1131 void* Ddate_prototype_setUTCDate(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1132 {
1133     // ECMA 15.9.5.33
1134     d_time date;
1135     d_time t;
1136     d_time day;
1137     d_time n;
1138 
1139     if(!othis.isDdate())
1140         return checkdate(ret, cc, TEXT_setUTCDate, othis);
1141 
1142     if(getThisTime(ret, othis, t) == 0)
1143     {
1144         if(!arglist.length)
1145             date = d_time_nan;
1146         else
1147             date = arglist[0].toDtime(cc);
1148         day = makeDay(yearFromTime(t), monthFromTime(t), date);
1149         n = timeClip(makeDate(day, timeWithinDay(t)));
1150         othis.value.putVtime(n);
1151         ret.putVtime(n);
1152     }
1153     return null;
1154 }
1155 
1156 void* Ddate_prototype_setMonth(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1157 {
1158     // ECMA 15.9.5.34
1159     d_time date;
1160     d_time month;
1161     d_time t;
1162     d_time day;
1163     d_time n;
1164 
1165     if(!othis.isDdate())
1166         return checkdate(ret, cc, TEXT_setMonth, othis);
1167 
1168     if(getThisLocalTime(ret, othis, t) == 0)
1169     {
1170         switch(arglist.length)
1171         {
1172         default:
1173         case 2:
1174             month = arglist[0].toDtime(cc);
1175             date = arglist[1].toDtime(cc);
1176             break;
1177 
1178         case 1:
1179             month = arglist[0].toDtime(cc);
1180             date = dateFromTime(t);
1181             break;
1182 
1183         case 0:
1184             month = d_time_nan;
1185             date = dateFromTime(t);
1186             break;
1187         }
1188         day = makeDay(yearFromTime(t), month, date);
1189         n = timeClip(localTimetoUTC(makeDate(day, timeWithinDay(t))));
1190         othis.value.putVtime(n);
1191         ret.putVtime(n);
1192     }
1193     return null;
1194 }
1195 
1196 void* Ddate_prototype_setUTCMonth(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1197 {
1198     // ECMA 15.9.5.35
1199     d_time date;
1200     d_time month;
1201     d_time t;
1202     d_time day;
1203     d_time n;
1204 
1205     if(!othis.isDdate())
1206         return checkdate(ret, cc, TEXT_setUTCMonth, othis);
1207 
1208     if(getThisTime(ret, othis, t) == 0)
1209     {
1210         switch(arglist.length)
1211         {
1212         default:
1213         case 2:
1214             month = arglist[0].toDtime(cc);
1215             date = arglist[1].toDtime(cc);
1216             break;
1217 
1218         case 1:
1219             month = arglist[0].toDtime(cc);
1220             date = dateFromTime(t);
1221             break;
1222 
1223         case 0:
1224             month = d_time_nan;
1225             date = dateFromTime(t);
1226             break;
1227         }
1228         day = makeDay(yearFromTime(t), month, date);
1229         n = timeClip(makeDate(day, timeWithinDay(t)));
1230         othis.value.putVtime(n);
1231         ret.putVtime(n);
1232     }
1233     return null;
1234 }
1235 
1236 void* Ddate_prototype_setFullYear(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1237 {
1238     // ECMA 15.9.5.36
1239     d_time date;
1240     d_time month;
1241     d_time year;
1242     d_time t;
1243     d_time day;
1244     d_time n;
1245 
1246     if(!othis.isDdate())
1247         return checkdate(ret, cc, TEXT_setFullYear, othis);
1248 
1249     if(getThisLocalTime(ret, othis, t))
1250         t = 0;
1251 
1252     switch(arglist.length)
1253     {
1254     default:
1255     case 3:
1256         date = arglist[2].toDtime(cc);
1257         month = arglist[1].toDtime(cc);
1258         year = arglist[0].toDtime(cc);
1259         break;
1260 
1261     case 2:
1262         date = dateFromTime(t);
1263         month = arglist[1].toDtime(cc);
1264         year = arglist[0].toDtime(cc);
1265         break;
1266 
1267     case 1:
1268         date = dateFromTime(t);
1269         month = monthFromTime(t);
1270         year = arglist[0].toDtime(cc);
1271         break;
1272 
1273     case 0:
1274         date = dateFromTime(t);
1275         month = monthFromTime(t);
1276         year = d_time_nan;
1277         break;
1278     }
1279     day = makeDay(year, month, date);
1280     n = timeClip(localTimetoUTC(makeDate(day, timeWithinDay(t))));
1281     othis.value.putVtime(n);
1282     ret.putVtime(n);
1283     return null;
1284 }
1285 
1286 void* Ddate_prototype_setUTCFullYear(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1287 {
1288     // ECMA 15.9.5.37
1289     d_time date;
1290     d_time month;
1291     d_time year;
1292     d_time t;
1293     d_time day;
1294     d_time n;
1295 
1296     if(!othis.isDdate())
1297         return checkdate(ret, cc, TEXT_setUTCFullYear, othis);
1298 
1299     getThisTime(ret, othis, t);
1300     if(t == d_time_nan)
1301         t = 0;
1302     switch(arglist.length)
1303     {
1304     default:
1305     case 3:
1306         month = arglist[2].toDtime(cc);
1307         date = arglist[1].toDtime(cc);
1308         year = arglist[0].toDtime(cc);
1309         break;
1310 
1311     case 2:
1312         month = monthFromTime(t);
1313         date = arglist[1].toDtime(cc);
1314         year = arglist[0].toDtime(cc);
1315         break;
1316 
1317     case 1:
1318         month = monthFromTime(t);
1319         date = dateFromTime(t);
1320         year = arglist[0].toDtime(cc);
1321         break;
1322 
1323     case 0:
1324         month = monthFromTime(t);
1325         date = dateFromTime(t);
1326         year = d_time_nan;
1327         break;
1328     }
1329     day = makeDay(year, month, date);
1330     n = timeClip(makeDate(day, timeWithinDay(t)));
1331     othis.value.putVtime(n);
1332     ret.putVtime(n);
1333     return null;
1334 }
1335 
1336 void* Ddate_prototype_setYear(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1337 {
1338     // ECMA 15.9.5.38
1339     d_time date;
1340     d_time month;
1341     d_time year;
1342     d_time t;
1343     d_time day;
1344     d_time n;
1345 
1346     if(!othis.isDdate())
1347         return checkdate(ret, cc, TEXT_setYear, othis);
1348 
1349     if(getThisLocalTime(ret, othis, t))
1350         t = 0;
1351     switch(arglist.length)
1352     {
1353     default:
1354     case 1:
1355         month = monthFromTime(t);
1356         date = dateFromTime(t);
1357         year = arglist[0].toDtime(cc);
1358         if(0 <= year && year <= 99)
1359             year += 1900;
1360         day = makeDay(year, month, date);
1361         n = timeClip(localTimetoUTC(makeDate(day, timeWithinDay(t))));
1362         break;
1363 
1364     case 0:
1365         n = d_time_nan;
1366         break;
1367     }
1368     othis.value.putVtime(n);
1369     ret.putVtime(n);
1370     return null;
1371 }
1372 
1373 void* Ddate_prototype_toLocaleString(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1374 {
1375     // ECMA 15.9.5.39
1376     immutable(char)[] s;
1377     d_time t;
1378 
1379     if(!othis.isDdate())
1380         return checkdate(ret, cc, TEXT_toLocaleString, othis);
1381 
1382     if(getThisLocalTime(ret, othis, t))
1383         t = 0;
1384 
1385     s = dateToString(cc, t, TIMEFORMAT.LocaleString);
1386     ret.putVstring(s);
1387     return null;
1388 }
1389 
1390 void* Ddate_prototype_toLocaleDateString(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1391 {
1392     // ECMA 15.9.5.6
1393     immutable(char)[] s;
1394     d_time t;
1395 
1396     if(!othis.isDdate())
1397         return checkdate(ret, cc, TEXT_toLocaleDateString, othis);
1398 
1399     if(getThisLocalTime(ret, othis, t))
1400         t = 0;
1401 
1402     s = dateToString(cc, t, TIMEFORMAT.LocaleDateString);
1403     ret.putVstring(s);
1404     return null;
1405 }
1406 
1407 void* Ddate_prototype_toLocaleTimeString(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1408 {
1409     // ECMA 15.9.5.7
1410     immutable(char)[] s;
1411     d_time t;
1412 
1413     if(!othis.isDdate())
1414         return checkdate(ret, cc, TEXT_toLocaleTimeString, othis);
1415 
1416     if(getThisLocalTime(ret, othis, t))
1417         t = 0;
1418     s = dateToString(cc, t, TIMEFORMAT.LocaleTimeString);
1419     ret.putVstring(s);
1420     return null;
1421 }
1422 
1423 void* Ddate_prototype_toUTCString(Dobject pthis, CallContext *cc, Dobject othis, Value* ret, Value[] arglist)
1424 {
1425     // ECMA 15.9.5.40
1426     immutable(char)[] s;
1427     d_time t;
1428 
1429     if(!othis.isDdate())
1430         return checkdate(ret, cc, TEXT_toUTCString, othis);
1431 
1432     if(getThisTime(ret, othis, t))
1433         t = 0;
1434     s = dateToString(cc, t, TIMEFORMAT.UTCString);
1435     ret.putVstring(s);
1436     return null;
1437 }
1438 
1439 /* ===================== Ddate_prototype ==================== */
1440 
1441 class DdatePrototype : Ddate
1442 {
1443     this(CallContext* cc)
1444     {
1445         super(cc, cc.tc.Dobject_prototype);
1446 
1447         Dobject f = cc.tc.Dfunction_prototype;
1448 
1449         Put(cc, TEXT_constructor, cc.tc.Ddate_constructor, DontEnum);
1450 
1451         static enum NativeFunctionData[] nfd =
1452         [
1453             { TEXT_toString, &Ddate_prototype_toString, 0 },
1454             { TEXT_toDateString, &Ddate_prototype_toDateString, 0 },
1455             { TEXT_toTimeString, &Ddate_prototype_toTimeString, 0 },
1456             { TEXT_valueOf, &Ddate_prototype_valueOf, 0 },
1457             { TEXT_getTime, &Ddate_prototype_getTime, 0 },
1458             //{	TEXT_getVarDate, &Ddate_prototype_getVarDate, 0 },
1459             { TEXT_getYear, &Ddate_prototype_getYear, 0 },
1460             { TEXT_getFullYear, &Ddate_prototype_getFullYear, 0 },
1461             { TEXT_getUTCFullYear, &Ddate_prototype_getUTCFullYear, 0 },
1462             { TEXT_getMonth, &Ddate_prototype_getMonth, 0 },
1463             { TEXT_getUTCMonth, &Ddate_prototype_getUTCMonth, 0 },
1464             { TEXT_getDate, &Ddate_prototype_getDate, 0 },
1465             { TEXT_getUTCDate, &Ddate_prototype_getUTCDate, 0 },
1466             { TEXT_getDay, &Ddate_prototype_getDay, 0 },
1467             { TEXT_getUTCDay, &Ddate_prototype_getUTCDay, 0 },
1468             { TEXT_getHours, &Ddate_prototype_getHours, 0 },
1469             { TEXT_getUTCHours, &Ddate_prototype_getUTCHours, 0 },
1470             { TEXT_getMinutes, &Ddate_prototype_getMinutes, 0 },
1471             { TEXT_getUTCMinutes, &Ddate_prototype_getUTCMinutes, 0 },
1472             { TEXT_getSeconds, &Ddate_prototype_getSeconds, 0 },
1473             { TEXT_getUTCSeconds, &Ddate_prototype_getUTCSeconds, 0 },
1474             { TEXT_getMilliseconds, &Ddate_prototype_getMilliseconds, 0 },
1475             { TEXT_getUTCMilliseconds, &Ddate_prototype_getUTCMilliseconds, 0 },
1476             { TEXT_getTimezoneOffset, &Ddate_prototype_getTimezoneOffset, 0 },
1477             { TEXT_setTime, &Ddate_prototype_setTime, 1 },
1478             { TEXT_setMilliseconds, &Ddate_prototype_setMilliseconds, 1 },
1479             { TEXT_setUTCMilliseconds, &Ddate_prototype_setUTCMilliseconds, 1 },
1480             { TEXT_setSeconds, &Ddate_prototype_setSeconds, 2 },
1481             { TEXT_setUTCSeconds, &Ddate_prototype_setUTCSeconds, 2 },
1482             { TEXT_setMinutes, &Ddate_prototype_setMinutes, 3 },
1483             { TEXT_setUTCMinutes, &Ddate_prototype_setUTCMinutes, 3 },
1484             { TEXT_setHours, &Ddate_prototype_setHours, 4 },
1485             { TEXT_setUTCHours, &Ddate_prototype_setUTCHours, 4 },
1486             { TEXT_setDate, &Ddate_prototype_setDate, 1 },
1487             { TEXT_setUTCDate, &Ddate_prototype_setUTCDate, 1 },
1488             { TEXT_setMonth, &Ddate_prototype_setMonth, 2 },
1489             { TEXT_setUTCMonth, &Ddate_prototype_setUTCMonth, 2 },
1490             { TEXT_setFullYear, &Ddate_prototype_setFullYear, 3 },
1491             { TEXT_setUTCFullYear, &Ddate_prototype_setUTCFullYear, 3 },
1492             { TEXT_setYear, &Ddate_prototype_setYear, 1 },
1493             { TEXT_toLocaleString, &Ddate_prototype_toLocaleString, 0 },
1494             { TEXT_toLocaleDateString, &Ddate_prototype_toLocaleDateString, 0 },
1495             { TEXT_toLocaleTimeString, &Ddate_prototype_toLocaleTimeString, 0 },
1496             { TEXT_toUTCString, &Ddate_prototype_toUTCString, 0 },
1497 
1498             // Map toGMTString() onto toUTCString(), per ECMA 15.9.5.41
1499             { TEXT_toGMTString, &Ddate_prototype_toUTCString, 0 },
1500         ];
1501 
1502         DnativeFunction.initialize(this, cc, nfd, DontEnum);
1503         assert(proptable.get("toString", Value.calcHash("toString")));
1504     }
1505 }
1506 
1507 
1508 /* ===================== Ddate ==================== */
1509 
1510 class Ddate : Dobject
1511 {
1512     this(CallContext* cc, d_number n)
1513     {
1514         super(cc, Ddate.getPrototype(cc));
1515         classname = TEXT_Date;
1516         value.putVnumber(n);
1517     }
1518 
1519     this(CallContext* cc, d_time n)
1520     {
1521         super(cc, Ddate.getPrototype(cc));
1522         classname = TEXT_Date;
1523         value.putVtime(n);
1524     }
1525 
1526     this(CallContext* cc, Dobject prototype)
1527     {
1528         super(cc, prototype);
1529         classname = TEXT_Date;
1530         value.putVnumber(d_number.nan);
1531     }
1532 
1533     static void initialize(CallContext* cc)
1534     {
1535         cc.tc.Ddate_constructor = new DdateConstructor(cc);
1536         cc.tc.Ddate_prototype = new DdatePrototype(cc);
1537 
1538         cc.tc.Ddate_constructor.Put(cc, TEXT_prototype, cc.tc.Ddate_prototype,
1539                                  DontEnum | DontDelete | ReadOnly);
1540 
1541         assert(cc.tc.Ddate_prototype.proptable.table.length != 0);
1542     }
1543 
1544     static Dfunction getConstructor(CallContext* cc)
1545     {
1546         return cc.tc.Ddate_constructor;
1547     }
1548 
1549     static Dobject getPrototype(CallContext* cc)
1550     {
1551         return cc.tc.Ddate_prototype;
1552     }
1553 }
1554 
1555