Beta merge 2
[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     /**
84      * The callback invoked when an object is used as the target of an 'instanceof' expression.
85      */
86     static bool hasInstance(JSContextRef context,
87             JSObjectRef constructor,
88             JSValueRef possibleInstance,
89             JSValueRef* exception);
90
91     static JSValueRef getTimezone(JSContextRef context, JSObjectRef function, 
92             JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
93     static JSValueRef toTimezone(JSContextRef context, JSObjectRef function, 
94         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
95         
96     static JSValueRef diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
97         
98     static JSValueRef difference(JSContextRef context, JSObjectRef function, 
99             JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
100     static JSValueRef equalsTo(JSContextRef context, JSObjectRef function, 
101         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
102     static JSValueRef earlierThan(JSContextRef context, JSObjectRef function, 
103         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
104     static JSValueRef laterThan(JSContextRef context, JSObjectRef function, 
105         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
106     static JSValueRef addDuration(JSContextRef context, JSObjectRef function, 
107         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
108     static JSValueRef toUTC(JSContextRef context, JSObjectRef function, 
109         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
110     static JSValueRef toLocalTimezone(JSContextRef context, JSObjectRef function, 
111         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
112
113     static JSValueRef toLocaleDateString(JSContextRef context, JSObjectRef function, 
114         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
115     static JSValueRef toLocaleTimeString(JSContextRef context, JSObjectRef function, 
116         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
117     static JSValueRef toLocaleString(JSContextRef context, JSObjectRef function, 
118         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
119     static JSValueRef toDateString(JSContextRef context, JSObjectRef function, 
120         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
121     static JSValueRef toTimeString(JSContextRef context, JSObjectRef function, 
122         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
123     static JSValueRef toString(JSContextRef context, JSObjectRef function, 
124         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
125         
126         static JSValueRef getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
127                 JSValueRef * exception);
128
129         static JSValueRef getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
130                 JSValueRef * exception);
131
132         static JSValueRef getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
133                 JSValueRef * exception);
134
135         static JSValueRef getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
136                 JSValueRef * exception);
137
138         static JSValueRef getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
139                 JSValueRef * exception);
140
141         static JSValueRef getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
142                 JSValueRef * exception);
143
144         static JSValueRef getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
145                 JSValueRef * exception);
146
147         static JSValueRef getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
148                 JSValueRef * exception);
149
150         static JSValueRef setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
151                         TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
152
153         static JSValueRef getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
154                         TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
155
156         static JSValueRef setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
157                         JSValueRef * exception);
158
159         static JSValueRef setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
160                         JSValueRef * exception);
161
162         static JSValueRef setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
163                 JSValueRef * exception);
164
165         static JSValueRef setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
166                 JSValueRef * exception);
167
168         static JSValueRef setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
169                 JSValueRef * exception);
170
171         static JSValueRef setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
172                 JSValueRef * exception);
173
174         static JSValueRef setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
175                 JSValueRef * exception);
176
177     static JSValueRef getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, 
178                 TizenApis::Api::TimeUtil::ITZDate::TZDateFields DateFields, JSValueRef * exception);    
179     static JSValueRef getUTCDate(JSContextRef context, JSObjectRef function, 
180         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
181     static JSValueRef getUTCDay(JSContextRef context, JSObjectRef function, 
182         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
183     static JSValueRef getUTCFullYear(JSContextRef context, JSObjectRef function, 
184         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
185     static JSValueRef getUTCHours(JSContextRef context, JSObjectRef function, 
186         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
187     static JSValueRef getUTCMilliseconds(JSContextRef context, JSObjectRef function, 
188         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
189     static JSValueRef getUTCMinutes(JSContextRef context, JSObjectRef function, 
190         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
191     static JSValueRef getUTCMonth(JSContextRef context, JSObjectRef function, 
192         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
193     static JSValueRef getUTCSeconds(JSContextRef context, JSObjectRef function, 
194         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
195
196     static JSValueRef setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, 
197                 const JSValueRef arguments[], TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields, JSValueRef * exception);
198     static JSValueRef setUTCDate(JSContextRef context, JSObjectRef function, 
199         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
200     static JSValueRef setUTCFullYear(JSContextRef context, JSObjectRef function, 
201         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
202     static JSValueRef setUTCHours(JSContextRef context, JSObjectRef function, 
203         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
204     static JSValueRef setUTCMilliseconds(JSContextRef context, JSObjectRef function, 
205         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
206     static JSValueRef setUTCMinutes(JSContextRef context, JSObjectRef function, 
207         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
208     static JSValueRef setUTCMonth(JSContextRef context, JSObjectRef function, 
209         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
210     static JSValueRef setUTCSeconds(JSContextRef context, JSObjectRef function, 
211         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
212
213     static JSValueRef getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
214                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);    
215     static JSValueRef secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
216                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
217     static JSValueRef isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
218                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
219     static JSValueRef getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
220                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
221     static JSValueRef getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
222                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
223 };
224
225 }
226 }
227
228 #endif /* _JS_TIZEN_DATETIME_H_ */