4d15f2703e2ed45591b2dd8c9a5ed720922d37f2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / TimeUtil / JSTZDate.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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. 
15  */
16
17
18
19
20 #ifndef _JS_TIZEN_TZDATE_H_
21 #define _JS_TIZEN_TZDATE_H_
22
23 #include <JavaScriptCore/JavaScript.h>
24 #include <API/TimeUtil/ITZDate.h>
25 #include <CommonsJavaScript/PrivateObject.h>
26
27 namespace TizenApis {
28 namespace Tizen1_0 {
29
30 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::TimeUtil::ITZDatePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> TZDatePrivObject;
31
32 class JSTZDate
33 {
34 public:
35
36     static const JSClassDefinition* getClassInfo();
37
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);        
45 private:
46         enum CompareType {
47                 DIFFERENCE,
48                 EQUALSTO,
49                 EARLIERTHAN,
50                 LATERTHAN
51                 };
52     /**
53      * This member variable contains the values which has to be passed when 
54      * the this class is embedded into JS Engine.
55      */
56     static JSClassDefinition m_classInfo;
57
58     /**
59      * This structure describes a statically declared function property.
60      */
61     static JSStaticFunction m_function[];
62
63     /**
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.
67      */
68
69     static JSClassRef m_jsClassRef;
70
71     /**
72      * The callback invoked when an object is first created.
73      */
74     static void initialize(JSContextRef context, JSObjectRef object);
75
76     /**
77      * The callback invoked when an object is finalized.
78      */
79     static void finalize(JSObjectRef object);
80
81     static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
82
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);
87         
88     static JSValueRef diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
89         
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);
104
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);
117         
118         static JSValueRef getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
119                 JSValueRef * exception);
120
121         static JSValueRef getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
122                 JSValueRef * exception);
123
124         static JSValueRef getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
125                 JSValueRef * exception);
126
127         static JSValueRef getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
128                 JSValueRef * exception);
129
130         static JSValueRef getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
131                 JSValueRef * exception);
132
133         static JSValueRef getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
134                 JSValueRef * exception);
135
136         static JSValueRef getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
137                 JSValueRef * exception);
138
139         static JSValueRef getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
140                 JSValueRef * exception);
141
142         static JSValueRef setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
143                         TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
144
145         static JSValueRef getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
146                         TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
147
148         static JSValueRef setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
149                         JSValueRef * exception);
150
151         static JSValueRef setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
152                         JSValueRef * exception);
153
154         static JSValueRef setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
155                 JSValueRef * exception);
156
157         static JSValueRef setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
158                 JSValueRef * exception);
159
160         static JSValueRef setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
161                 JSValueRef * exception);
162
163         static JSValueRef setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
164                 JSValueRef * exception);
165
166         static JSValueRef setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
167                 JSValueRef * exception);
168
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);
187
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);
204
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);
215 };
216
217 }
218 }
219
220 #endif /* _JS_TIZEN_DATETIME_H_ */