]> git.saurik.com Git - apple/javascriptcore.git/blob - kjs/date_object.h
JavaScriptCore-461.tar.gz
[apple/javascriptcore.git] / kjs / date_object.h
1 /*
2 * This file is part of the KDE libraries
3 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21 #ifndef DATE_OBJECT_H
22 #define DATE_OBJECT_H
23
24 #include "function.h"
25 #include "JSWrapperObject.h"
26 #include "lookup.h"
27
28 namespace KJS {
29
30 struct GregorianDateTime;
31
32 class FunctionPrototype;
33 class ObjectPrototype;
34
35 class DateInstance : public JSWrapperObject {
36 public:
37 DateInstance(JSObject *proto);
38
39 bool getTime(GregorianDateTime&, int& offset) const;
40 bool getUTCTime(GregorianDateTime&) const;
41 bool getTime(double& milli, int& offset) const;
42 bool getUTCTime(double& milli) const;
43
44 virtual const ClassInfo *classInfo() const { return &info; }
45 static const ClassInfo info;
46 };
47
48 /**
49 * @internal
50 *
51 * The initial value of Date.prototype (and thus all objects created
52 * with the Date constructor
53 */
54 class DatePrototype : public DateInstance {
55 public:
56 DatePrototype(ExecState *, ObjectPrototype *);
57 virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
58 virtual const ClassInfo *classInfo() const { return &info; }
59 static const ClassInfo info;
60 };
61
62 /**
63 * @internal
64 *
65 * Functions to implement all methods that are properties of the
66 * Date.prototype object
67 */
68
69 // Non-normative properties (Appendix B)
70 // GetYear, SetYear, ToGMTString
71
72 JSValue* dateProtoFuncToString(ExecState*, JSObject*, const List&);
73 JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, const List&);
74 JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, const List&);
75 JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, const List&);
76 JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, const List&);
77 JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, const List&);
78 JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, const List&);
79 JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, const List&);
80 JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, const List&);
81 JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, const List&);
82 JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, const List&);
83 JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, const List&);
84 JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, const List&);
85 JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, const List&);
86 JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, const List&);
87 JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, const List&);
88 JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, const List&);
89 JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, const List&);
90 JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, const List&);
91 JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, const List&);
92 JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, const List&);
93 JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, const List&);
94 JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, const List&);
95 JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, const List&);
96 JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, const List&);
97 JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, const List&);
98 JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, const List&);
99 JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, const List&);
100 JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, const List&);
101 JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, const List&);
102 JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, const List&);
103 JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, const List&);
104 JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, const List&);
105 JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, const List&);
106 JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, const List&);
107 JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, const List&);
108 JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, const List&);
109 JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, const List&);
110 JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, const List&);
111 JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, const List&);
112 JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, const List&);
113 JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, const List&);
114 JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, const List&);
115 JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, const List&);
116
117 /**
118 * @internal
119 *
120 * The initial value of the the global variable's "Date" property
121 */
122 class DateObjectImp : public InternalFunctionImp {
123 public:
124 DateObjectImp(ExecState *, FunctionPrototype *, DatePrototype *);
125
126 virtual bool implementsConstruct() const;
127 virtual JSObject *construct(ExecState *, const List &args);
128 virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args);
129
130 JSObject *construct(const List &);
131 };
132
133 } // namespace
134
135 #endif