Git Init
[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 Api::TimeUtil::TZDateProperties &properties);
41     static JSObjectRef createJSObject(JSContextRef context, const time_t localTime, const std::string &timezone);
42     static JSObjectRef createJSObject(JSContextRef context, const long year, const long month,  const long day, const long hours, const long minutes, const long seconds, const std::string &timezone);         
43 private:
44         enum CompareType {
45                 DIFFERENCE,
46                 EQUALSTO,
47                 EARLIERTHAN,
48                 LATERTHAN
49                 };
50     /**
51      * This member variable contains the values which has to be passed when 
52      * the this class is embedded into JS Engine.
53      */
54     static JSClassDefinition m_classInfo;
55
56     /**
57      * This structure describes a statically declared function property.
58      */
59     static JSStaticFunction m_function[];
60
61     /**
62      * This member variable contains the initialization values for the 
63      * properties of this class. The values are given according to the
64      * data structure JSPropertySpec.
65      */
66
67     static JSClassRef m_jsClassRef;
68
69     /**
70      * The callback invoked when an object is first created.
71      */
72     static void initialize(JSContextRef context, JSObjectRef object);
73
74     /**
75      * The callback invoked when an object is finalized.
76      */
77     static void finalize(JSObjectRef object);
78
79     static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
80
81     static JSValueRef getTimezone(JSContextRef context, JSObjectRef function, 
82             JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
83     static JSValueRef toTimezone(JSContextRef context, JSObjectRef function, 
84         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
85         
86     static JSValueRef diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
87         
88     static JSValueRef difference(JSContextRef context, JSObjectRef function, 
89             JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
90     static JSValueRef equalsTo(JSContextRef context, JSObjectRef function, 
91         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
92     static JSValueRef earlierThan(JSContextRef context, JSObjectRef function, 
93         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
94     static JSValueRef laterThan(JSContextRef context, JSObjectRef function, 
95         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
96     static JSValueRef addDuration(JSContextRef context, JSObjectRef function, 
97         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
98     static JSValueRef toUTC(JSContextRef context, JSObjectRef function, 
99         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
100     static JSValueRef toLocalTimezone(JSContextRef context, JSObjectRef function, 
101         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
102
103     static JSValueRef toLocaleDateString(JSContextRef context, JSObjectRef function, 
104         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
105     static JSValueRef toLocaleTimeString(JSContextRef context, JSObjectRef function, 
106         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
107     static JSValueRef toLocaleString(JSContextRef context, JSObjectRef function, 
108         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
109     static JSValueRef toDateString(JSContextRef context, JSObjectRef function, 
110         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
111     static JSValueRef toTimeString(JSContextRef context, JSObjectRef function, 
112         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
113     static JSValueRef toString(JSContextRef context, JSObjectRef function, 
114         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
115         
116         static JSValueRef getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
117                 JSValueRef * exception);
118
119         static JSValueRef getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
120                 JSValueRef * exception);
121
122         static JSValueRef getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
123                 JSValueRef * exception);
124
125         static JSValueRef getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
126                 JSValueRef * exception);
127
128         static JSValueRef getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
129                 JSValueRef * exception);
130
131         static JSValueRef getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
132                 JSValueRef * exception);
133
134         static JSValueRef getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
135                 JSValueRef * exception);
136
137         static JSValueRef getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
138                 JSValueRef * exception);
139
140         static JSValueRef setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], size_t argumentIndex, JSValueRef * exception,
141                         TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields, int minData, int maxData);
142
143         static JSValueRef getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
144                         TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields);
145
146         static JSValueRef setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
147                         JSValueRef * exception);
148
149         static JSValueRef setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
150                         JSValueRef * exception);
151
152         static JSValueRef setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
153                 JSValueRef * exception);
154
155         static JSValueRef setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
156                 JSValueRef * exception);
157
158         static JSValueRef setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
159                 JSValueRef * exception);
160
161         static JSValueRef setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
162                 JSValueRef * exception);
163
164         static JSValueRef setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
165                 JSValueRef * exception);
166
167     static JSValueRef getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject,
168                 TizenApis::Api::TimeUtil::ITZDate::TZDateFields DateFields, JSValueRef * exception);    
169     static JSValueRef getUTCDate(JSContextRef context, JSObjectRef function, 
170         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
171     static JSValueRef getUTCDay(JSContextRef context, JSObjectRef function, 
172         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
173     static JSValueRef getUTCFullYear(JSContextRef context, JSObjectRef function, 
174         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
175     static JSValueRef getUTCHours(JSContextRef context, JSObjectRef function, 
176         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
177     static JSValueRef getUTCMilliseconds(JSContextRef context, JSObjectRef function, 
178         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
179     static JSValueRef getUTCMinutes(JSContextRef context, JSObjectRef function, 
180         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
181     static JSValueRef getUTCMonth(JSContextRef context, JSObjectRef function, 
182         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
183     static JSValueRef getUTCSeconds(JSContextRef context, JSObjectRef function, 
184         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
185
186     static JSValueRef setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, 
187                 const JSValueRef arguments[], TizenApis::Api::TimeUtil::ITZDate::TZDateFields dateFields, JSValueRef * exception, int minData, int maxData);
188     static JSValueRef setUTCDate(JSContextRef context, JSObjectRef function, 
189         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
190     static JSValueRef setUTCFullYear(JSContextRef context, JSObjectRef function, 
191         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
192     static JSValueRef setUTCHours(JSContextRef context, JSObjectRef function, 
193         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
194     static JSValueRef setUTCMilliseconds(JSContextRef context, JSObjectRef function, 
195         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
196     static JSValueRef setUTCMinutes(JSContextRef context, JSObjectRef function, 
197         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
198     static JSValueRef setUTCMonth(JSContextRef context, JSObjectRef function, 
199         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
200     static JSValueRef setUTCSeconds(JSContextRef context, JSObjectRef function, 
201         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
202
203     static JSValueRef getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
204                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);    
205     static JSValueRef secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
206                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
207     static JSValueRef isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
208                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
209     static JSValueRef getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
210                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
211     static JSValueRef getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, 
212                 size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
213 };
214
215 }
216 }
217
218 #endif /* _JS_TIZEN_DATETIME_H_ */