tizen 2.3 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / TimeUtil / JSTZDate.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef __TIZEN_JS_TZDATE_H_
19 #define __TIZEN_JS_TZDATE_H_
20
21 #include <JavaScriptCore/JavaScript.h>
22 #include "TZDate.h"
23
24 namespace DeviceAPI {
25 namespace Time {
26
27 #ifdef IMPL_BACKWARD_COMPATIBLE
28 struct TZDateHolder {
29     TZDatePtr ptr;
30 };
31 #endif //IMPL_BACKWARD_COMPATIBLE
32
33 class JSTZDate {
34 public:
35
36     static const JSClassDefinition* getClassInfo();
37     static const JSClassRef getClassRef();
38
39     static JSObjectRef constructor(JSContextRef context,
40             JSObjectRef constructor,
41             size_t argumentCount,
42             const JSValueRef arguments[],
43             JSValueRef* exception);
44
45     static TZDatePtr getPrivateObject(JSContextRef context, JSValueRef value);
46
47     static void setPrivateObject(JSObjectRef object, TZDatePtr native);
48
49     static JSObjectRef makeJSObject(JSContextRef context, TZDatePtr native);
50
51 #ifdef IMPL_BACKWARD_COMPATIBLE
52
53     static JSObjectRef createJSObject(JSContextRef context, TZDatePtr tzDate);
54     static JSObjectRef createJSObject(JSContextRef context, const bool isNotNull = true);
55     static JSObjectRef createJSObject(JSContextRef context, const std::string &timezone);
56     static JSObjectRef createJSObject(JSContextRef context, const double milliseconds, const std::string &timezone);
57     static JSObjectRef createJSObject(JSContextRef context, const TZDateProperties &properties);
58     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);
59     static JSObjectRef createJSObject(JSContextRef context, const std::string &dateString, const double milliseconds, const std::string &timezone);
60
61 #endif //IMPL_BACKWARD_COMPATIBLE
62
63 private:
64     /**
65      * This member variable contains the values which has to be passed when
66      * the this class is embedded into JS Engine.
67      */
68     static JSClassDefinition m_classInfo;
69
70     /**
71      * This structure describes a statically declared function property.
72      */
73     static JSStaticFunction m_function[];
74
75     static JSClassRef m_jsClassRef;
76
77     /**
78      * The callback invoked when an object is first created.
79      */
80     static void initialize(JSContextRef context, JSObjectRef object);
81
82     /**
83      * The callback invoked when an object is finalized.
84      */
85     static void finalize(JSObjectRef object);
86
87     /**
88      * Functions declaration for the JSTZDate interface.
89      */
90     static JSValueRef getDate(JSContextRef context,
91             JSObjectRef function,
92             JSObjectRef thisObject,
93             size_t argumentCount,
94             const JSValueRef arguments[],
95             JSValueRef * exception);
96
97     static JSValueRef setDate(JSContextRef context,
98             JSObjectRef function,
99             JSObjectRef thisObject,
100             size_t argumentCount,
101             const JSValueRef arguments[],
102             JSValueRef * exception);
103
104     static JSValueRef getDay(JSContextRef context,
105             JSObjectRef function,
106             JSObjectRef thisObject,
107             size_t argumentCount,
108             const JSValueRef arguments[],
109             JSValueRef * exception);
110
111     static JSValueRef getFullYear(JSContextRef context,
112             JSObjectRef function,
113             JSObjectRef thisObject,
114             size_t argumentCount,
115             const JSValueRef arguments[],
116             JSValueRef * exception);
117
118     static JSValueRef setFullYear(JSContextRef context,
119             JSObjectRef function,
120             JSObjectRef thisObject,
121             size_t argumentCount,
122             const JSValueRef arguments[],
123             JSValueRef * exception);
124
125     static JSValueRef getHours(JSContextRef context,
126             JSObjectRef function,
127             JSObjectRef thisObject,
128             size_t argumentCount,
129             const JSValueRef arguments[],
130             JSValueRef * exception);
131
132     static JSValueRef setHours(JSContextRef context,
133             JSObjectRef function,
134             JSObjectRef thisObject,
135             size_t argumentCount,
136             const JSValueRef arguments[],
137             JSValueRef * exception);
138
139     static JSValueRef getMilliseconds(JSContextRef context,
140             JSObjectRef function,
141             JSObjectRef thisObject,
142             size_t argumentCount,
143             const JSValueRef arguments[],
144             JSValueRef * exception);
145
146     static JSValueRef setMilliseconds(JSContextRef context,
147             JSObjectRef function,
148             JSObjectRef thisObject,
149             size_t argumentCount,
150             const JSValueRef arguments[],
151             JSValueRef * exception);
152
153     static JSValueRef getMinutes(JSContextRef context,
154             JSObjectRef function,
155             JSObjectRef thisObject,
156             size_t argumentCount,
157             const JSValueRef arguments[],
158             JSValueRef * exception);
159
160     static JSValueRef setMinutes(JSContextRef context,
161             JSObjectRef function,
162             JSObjectRef thisObject,
163             size_t argumentCount,
164             const JSValueRef arguments[],
165             JSValueRef * exception);
166
167     static JSValueRef getMonth(JSContextRef context,
168             JSObjectRef function,
169             JSObjectRef thisObject,
170             size_t argumentCount,
171             const JSValueRef arguments[],
172             JSValueRef * exception);
173
174     static JSValueRef setMonth(JSContextRef context,
175             JSObjectRef function,
176             JSObjectRef thisObject,
177             size_t argumentCount,
178             const JSValueRef arguments[],
179             JSValueRef * exception);
180
181     static JSValueRef getSeconds(JSContextRef context,
182             JSObjectRef function,
183             JSObjectRef thisObject,
184             size_t argumentCount,
185             const JSValueRef arguments[],
186             JSValueRef * exception);
187
188     static JSValueRef setSeconds(JSContextRef context,
189             JSObjectRef function,
190             JSObjectRef thisObject,
191             size_t argumentCount,
192             const JSValueRef arguments[],
193             JSValueRef * exception);
194
195     static JSValueRef getUTCDate(JSContextRef context,
196             JSObjectRef function,
197             JSObjectRef thisObject,
198             size_t argumentCount,
199             const JSValueRef arguments[],
200             JSValueRef * exception);
201
202     static JSValueRef setUTCDate(JSContextRef context,
203             JSObjectRef function,
204             JSObjectRef thisObject,
205             size_t argumentCount,
206             const JSValueRef arguments[],
207             JSValueRef * exception);
208
209     static JSValueRef getUTCDay(JSContextRef context,
210             JSObjectRef function,
211             JSObjectRef thisObject,
212             size_t argumentCount,
213             const JSValueRef arguments[],
214             JSValueRef * exception);
215
216     static JSValueRef getUTCFullYear(JSContextRef context,
217             JSObjectRef function,
218             JSObjectRef thisObject,
219             size_t argumentCount,
220             const JSValueRef arguments[],
221             JSValueRef * exception);
222
223     static JSValueRef setUTCFullYear(JSContextRef context,
224             JSObjectRef function,
225             JSObjectRef thisObject,
226             size_t argumentCount,
227             const JSValueRef arguments[],
228             JSValueRef * exception);
229
230     static JSValueRef getUTCHours(JSContextRef context,
231             JSObjectRef function,
232             JSObjectRef thisObject,
233             size_t argumentCount,
234             const JSValueRef arguments[],
235             JSValueRef * exception);
236
237     static JSValueRef setUTCHours(JSContextRef context,
238             JSObjectRef function,
239             JSObjectRef thisObject,
240             size_t argumentCount,
241             const JSValueRef arguments[],
242             JSValueRef * exception);
243
244     static JSValueRef getUTCMilliseconds(JSContextRef context,
245             JSObjectRef function,
246             JSObjectRef thisObject,
247             size_t argumentCount,
248             const JSValueRef arguments[],
249             JSValueRef * exception);
250
251     static JSValueRef setUTCMilliseconds(JSContextRef context,
252             JSObjectRef function,
253             JSObjectRef thisObject,
254             size_t argumentCount,
255             const JSValueRef arguments[],
256             JSValueRef * exception);
257
258     static JSValueRef getUTCMinutes(JSContextRef context,
259             JSObjectRef function,
260             JSObjectRef thisObject,
261             size_t argumentCount,
262             const JSValueRef arguments[],
263             JSValueRef * exception);
264
265     static JSValueRef setUTCMinutes(JSContextRef context,
266             JSObjectRef function,
267             JSObjectRef thisObject,
268             size_t argumentCount,
269             const JSValueRef arguments[],
270             JSValueRef * exception);
271
272     static JSValueRef getUTCMonth(JSContextRef context,
273             JSObjectRef function,
274             JSObjectRef thisObject,
275             size_t argumentCount,
276             const JSValueRef arguments[],
277             JSValueRef * exception);
278
279     static JSValueRef setUTCMonth(JSContextRef context,
280             JSObjectRef function,
281             JSObjectRef thisObject,
282             size_t argumentCount,
283             const JSValueRef arguments[],
284             JSValueRef * exception);
285
286     static JSValueRef getUTCSeconds(JSContextRef context,
287             JSObjectRef function,
288             JSObjectRef thisObject,
289             size_t argumentCount,
290             const JSValueRef arguments[],
291             JSValueRef * exception);
292
293     static JSValueRef setUTCSeconds(JSContextRef context,
294             JSObjectRef function,
295             JSObjectRef thisObject,
296             size_t argumentCount,
297             const JSValueRef arguments[],
298             JSValueRef * exception);
299
300     static JSValueRef getTimezone(JSContextRef context,
301             JSObjectRef function,
302             JSObjectRef thisObject,
303             size_t argumentCount,
304             const JSValueRef arguments[],
305             JSValueRef * exception);
306
307     static JSValueRef toTimezone(JSContextRef context,
308             JSObjectRef function,
309             JSObjectRef thisObject,
310             size_t argumentCount,
311             const JSValueRef arguments[],
312             JSValueRef * exception);
313
314     static JSValueRef toLocalTimezone(JSContextRef context,
315             JSObjectRef function,
316             JSObjectRef thisObject,
317             size_t argumentCount,
318             const JSValueRef arguments[],
319             JSValueRef * exception);
320
321     static JSValueRef toUTC(JSContextRef context,
322             JSObjectRef function,
323             JSObjectRef thisObject,
324             size_t argumentCount,
325             const JSValueRef arguments[],
326             JSValueRef * exception);
327
328     static JSValueRef difference(JSContextRef context,
329             JSObjectRef function,
330             JSObjectRef thisObject,
331             size_t argumentCount,
332             const JSValueRef arguments[],
333             JSValueRef * exception);
334
335     static JSValueRef equalsTo(JSContextRef context,
336             JSObjectRef function,
337             JSObjectRef thisObject,
338             size_t argumentCount,
339             const JSValueRef arguments[],
340             JSValueRef * exception);
341
342     static JSValueRef earlierThan(JSContextRef context,
343             JSObjectRef function,
344             JSObjectRef thisObject,
345             size_t argumentCount,
346             const JSValueRef arguments[],
347             JSValueRef * exception);
348
349     static JSValueRef laterThan(JSContextRef context,
350             JSObjectRef function,
351             JSObjectRef thisObject,
352             size_t argumentCount,
353             const JSValueRef arguments[],
354             JSValueRef * exception);
355
356     static JSValueRef addDuration(JSContextRef context,
357             JSObjectRef function,
358             JSObjectRef thisObject,
359             size_t argumentCount,
360             const JSValueRef arguments[],
361             JSValueRef * exception);
362
363     static JSValueRef toLocaleDateString(JSContextRef context,
364             JSObjectRef function,
365             JSObjectRef thisObject,
366             size_t argumentCount,
367             const JSValueRef arguments[],
368             JSValueRef * exception);
369
370     static JSValueRef toLocaleTimeString(JSContextRef context,
371             JSObjectRef function,
372             JSObjectRef thisObject,
373             size_t argumentCount,
374             const JSValueRef arguments[],
375             JSValueRef * exception);
376
377     static JSValueRef toLocaleString(JSContextRef context,
378             JSObjectRef function,
379             JSObjectRef thisObject,
380             size_t argumentCount,
381             const JSValueRef arguments[],
382             JSValueRef * exception);
383
384     static JSValueRef toDateString(JSContextRef context,
385             JSObjectRef function,
386             JSObjectRef thisObject,
387             size_t argumentCount,
388             const JSValueRef arguments[],
389             JSValueRef * exception);
390
391     static JSValueRef toTimeString(JSContextRef context,
392             JSObjectRef function,
393             JSObjectRef thisObject,
394             size_t argumentCount,
395             const JSValueRef arguments[],
396             JSValueRef * exception);
397
398     static JSValueRef toString(JSContextRef context,
399             JSObjectRef function,
400             JSObjectRef thisObject,
401             size_t argumentCount,
402             const JSValueRef arguments[],
403             JSValueRef * exception);
404
405     static JSValueRef getTimezoneAbbreviation(JSContextRef context,
406             JSObjectRef function,
407             JSObjectRef thisObject,
408             size_t argumentCount,
409             const JSValueRef arguments[],
410             JSValueRef * exception);
411
412     static JSValueRef secondsFromUTC(JSContextRef context,
413             JSObjectRef function,
414             JSObjectRef thisObject,
415             size_t argumentCount,
416             const JSValueRef arguments[],
417             JSValueRef * exception);
418
419     static JSValueRef isDST(JSContextRef context,
420             JSObjectRef function,
421             JSObjectRef thisObject,
422             size_t argumentCount,
423             const JSValueRef arguments[],
424             JSValueRef * exception);
425
426     static JSValueRef getPreviousDSTTransition(JSContextRef context,
427             JSObjectRef function,
428             JSObjectRef thisObject,
429             size_t argumentCount,
430             const JSValueRef arguments[],
431             JSValueRef * exception);
432
433     static JSValueRef getNextDSTTransition(JSContextRef context,
434             JSObjectRef function,
435             JSObjectRef thisObject,
436             size_t argumentCount,
437             const JSValueRef arguments[],
438             JSValueRef * exception);
439 };
440
441 }
442 }
443
444 #endif // __TIZEN_JS_TZDATE_H_