2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #ifndef _JS_TIZEN_TZDATE_H_
21 #define _JS_TIZEN_TZDATE_H_
23 #include <JavaScriptCore/JavaScript.h>
24 #include <API/TimeUtil/ITZDate.h>
25 #include <CommonsJavaScript/PrivateObject.h>
30 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::TimeUtil::ITZDatePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> TZDatePrivObject;
36 static const JSClassDefinition* getClassInfo();
38 static const JSClassRef getClassRef();
39 static JSObjectRef createJSObject(JSContextRef context);
40 static JSObjectRef createJSObject(JSContextRef context, const std::string &timezone);
41 static JSObjectRef createJSObject(JSContextRef context, const Api::TimeUtil::TZDateProperties &properties);
42 static JSObjectRef createJSObject(JSContextRef context, const time_t localTime, const std::string &timezone);
43 static JSObjectRef createJSObject(JSContextRef context, const time_t localTime, const long msec, const std::string &timezone);
44 static JSObjectRef createJSObject(JSContextRef context, const long year, const long month, const long day, const long hours, const long minutes, const long seconds, const long milliseconds, const std::string &timezone);
53 * This member variable contains the values which has to be passed when
54 * the this class is embedded into JS Engine.
56 static JSClassDefinition m_classInfo;
59 * This structure describes a statically declared function property.
61 static JSStaticFunction m_function[];
64 * This member variable contains the initialization values for the
65 * properties of this class. The values are given according to the
66 * data structure JSPropertySpec.
69 static JSClassRef m_jsClassRef;
72 * The callback invoked when an object is first created.
74 static void initialize(JSContextRef context, JSObjectRef object);
77 * The callback invoked when an object is finalized.
79 static void finalize(JSObjectRef object);
81 static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
83 static JSValueRef getTimezone(JSContextRef context, JSObjectRef function,
84 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
85 static JSValueRef toTimezone(JSContextRef context, JSObjectRef function,
86 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
88 static JSValueRef diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
90 static JSValueRef difference(JSContextRef context, JSObjectRef function,
91 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
92 static JSValueRef equalsTo(JSContextRef context, JSObjectRef function,
93 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
94 static JSValueRef earlierThan(JSContextRef context, JSObjectRef function,
95 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
96 static JSValueRef laterThan(JSContextRef context, JSObjectRef function,
97 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
98 static JSValueRef addDuration(JSContextRef context, JSObjectRef function,
99 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
100 static JSValueRef toUTC(JSContextRef context, JSObjectRef function,
101 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
102 static JSValueRef toLocalTimezone(JSContextRef context, JSObjectRef function,
103 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
105 static JSValueRef toLocaleDateString(JSContextRef context, JSObjectRef function,
106 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
107 static JSValueRef toLocaleTimeString(JSContextRef context, JSObjectRef function,
108 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
109 static JSValueRef toLocaleString(JSContextRef context, JSObjectRef function,
110 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
111 static JSValueRef toDateString(JSContextRef context, JSObjectRef function,
112 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
113 static JSValueRef toTimeString(JSContextRef context, JSObjectRef function,
114 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
115 static JSValueRef toString(JSContextRef context, JSObjectRef function,
116 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
118 static JSValueRef getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
119 JSValueRef * exception);
121 static JSValueRef getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
122 JSValueRef * exception);
124 static JSValueRef getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
125 JSValueRef * exception);
127 static JSValueRef getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
128 JSValueRef * exception);
130 static JSValueRef getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
131 JSValueRef * exception);
133 static JSValueRef getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
134 JSValueRef * exception);
136 static JSValueRef getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
137 JSValueRef * exception);
139 static JSValueRef getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
140 JSValueRef * exception);
142 static JSValueRef setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
143 TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
145 static JSValueRef getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
146 TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
148 static JSValueRef setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
149 JSValueRef * exception);
151 static JSValueRef setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
152 JSValueRef * exception);
154 static JSValueRef setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
155 JSValueRef * exception);
157 static JSValueRef setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
158 JSValueRef * exception);
160 static JSValueRef setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
161 JSValueRef * exception);
163 static JSValueRef setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
164 JSValueRef * exception);
166 static JSValueRef setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
167 JSValueRef * exception);
169 static JSValueRef getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount,
170 TizenApis::Api::TimeUtil::ITZDate::TZDateFields DateFields, JSValueRef * exception);
171 static JSValueRef getUTCDate(JSContextRef context, JSObjectRef function,
172 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
173 static JSValueRef getUTCDay(JSContextRef context, JSObjectRef function,
174 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
175 static JSValueRef getUTCFullYear(JSContextRef context, JSObjectRef function,
176 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
177 static JSValueRef getUTCHours(JSContextRef context, JSObjectRef function,
178 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
179 static JSValueRef getUTCMilliseconds(JSContextRef context, JSObjectRef function,
180 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
181 static JSValueRef getUTCMinutes(JSContextRef context, JSObjectRef function,
182 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
183 static JSValueRef getUTCMonth(JSContextRef context, JSObjectRef function,
184 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
185 static JSValueRef getUTCSeconds(JSContextRef context, JSObjectRef function,
186 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
188 static JSValueRef setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount,
189 const JSValueRef arguments[], TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields, JSValueRef * exception);
190 static JSValueRef setUTCDate(JSContextRef context, JSObjectRef function,
191 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
192 static JSValueRef setUTCFullYear(JSContextRef context, JSObjectRef function,
193 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
194 static JSValueRef setUTCHours(JSContextRef context, JSObjectRef function,
195 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
196 static JSValueRef setUTCMilliseconds(JSContextRef context, JSObjectRef function,
197 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
198 static JSValueRef setUTCMinutes(JSContextRef context, JSObjectRef function,
199 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
200 static JSValueRef setUTCMonth(JSContextRef context, JSObjectRef function,
201 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
202 static JSValueRef setUTCSeconds(JSContextRef context, JSObjectRef function,
203 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
205 static JSValueRef getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
206 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
207 static JSValueRef secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
208 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
209 static JSValueRef isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
210 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
211 static JSValueRef getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
212 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
213 static JSValueRef getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
214 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
220 #endif /* _JS_TIZEN_DATETIME_H_ */