815d801cbdc2693802a35b4319690891679f5603
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / TimeUtil / JSTZDate.cpp
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 #include <ctime>
21 #include <string>
22 #include <dpl/log/log.h>
23
24 #include <CommonsJavaScript/PrivateObject.h>
25 #include <CommonsJavaScript/JSUtils.h>
26 #include <Commons/Exception.h>
27 #include <Tizen/Common/JSTizenExceptionFactory.h>
28 #include <Tizen/Common/JSTizenException.h>
29
30 #include <API/TimeUtil/DurationProperties.h>
31 #include <API/TimeUtil/TimeUtilFactory.h>
32
33 #include "JSTZDate.h"
34 #include "TimeUtilConverter.h"
35 #include "plugin_config.h"
36
37 using namespace TizenApis::Api::TimeUtil;
38 using namespace TizenApis::Commons;
39 using namespace WrtDeviceApis::Commons;
40 using namespace WrtDeviceApis::CommonsJavaScript;
41
42 #define min(a,b) (((a) < (b)) ? (a) : (b))
43
44 #define TIZEN10_TZDATE_ATTRIBUTENAME   "TZDate"
45
46 namespace TizenApis {
47 namespace Tizen1_0 {
48
49 JSClassDefinition JSTZDate::m_classInfo =
50 {
51     0,
52     kJSClassAttributeNone,
53     TIZEN10_TZDATE_ATTRIBUTENAME,
54     0,
55     NULL,//property,
56     m_function,
57     initialize,
58     finalize,
59     NULL, //hasProperty,
60     NULL, //getProperty,
61     NULL, //setProperty,
62     NULL, //DeleteProperty,
63     NULL, //GetPropertyNames,
64     NULL, //CallAsFunction,
65     constructor, //CallAsConstructor,
66     NULL, //HasInstance,
67     NULL  //ConvertToType
68 };
69
70 JSStaticFunction JSTZDate::m_function[] = {
71     {"getDate",           JSTZDate::getDate,            kJSPropertyAttributeNone},
72     {"getDay",            JSTZDate::getDay,             kJSPropertyAttributeNone},
73     {"getFullYear",       JSTZDate::getFullYear,        kJSPropertyAttributeNone},
74     {"getHours",          JSTZDate::getHours,           kJSPropertyAttributeNone},
75     {"getMilliseconds",   JSTZDate::getMilliseconds,    kJSPropertyAttributeNone},
76     {"getMinutes",        JSTZDate::getMinutes,         kJSPropertyAttributeNone},
77     {"getMonth",          JSTZDate::getMonth,           kJSPropertyAttributeNone},
78     {"getSeconds",        JSTZDate::getSeconds,         kJSPropertyAttributeNone},
79
80     {"setDate",           JSTZDate::setDate,           kJSPropertyAttributeNone},
81     {"setFullYear",       JSTZDate::setFullYear,       kJSPropertyAttributeNone},
82     {"setHours",          JSTZDate::setHours,          kJSPropertyAttributeNone},
83     {"setMilliseconds",   JSTZDate::setMilliseconds,   kJSPropertyAttributeNone},
84     {"setMinutes",        JSTZDate::setMinutes,        kJSPropertyAttributeNone},
85     {"setMonth",          JSTZDate::setMonth,          kJSPropertyAttributeNone},
86     {"setSeconds",        JSTZDate::setSeconds,        kJSPropertyAttributeNone},
87
88     {"getUTCDate", JSTZDate::getUTCDate, kJSPropertyAttributeNone},
89     {"getUTCDay", JSTZDate::getUTCDay, kJSPropertyAttributeNone},
90     {"getUTCFullYear", JSTZDate::getUTCFullYear, kJSPropertyAttributeNone},
91     {"getUTCHours", JSTZDate::getUTCHours, kJSPropertyAttributeNone},
92     {"getUTCMilliseconds", JSTZDate::getUTCMilliseconds, kJSPropertyAttributeNone},
93     {"getUTCMinutes", JSTZDate::getUTCMinutes, kJSPropertyAttributeNone},
94     {"getUTCMonth", JSTZDate::getUTCMonth, kJSPropertyAttributeNone},
95     {"getUTCSeconds", JSTZDate::getUTCSeconds, kJSPropertyAttributeNone},
96
97     {"setUTCDate", JSTZDate::setUTCDate, kJSPropertyAttributeNone},
98     {"setUTCFullYear", JSTZDate::setUTCFullYear, kJSPropertyAttributeNone},
99     {"setUTCHours", JSTZDate::setUTCHours, kJSPropertyAttributeNone},
100     {"setUTCMilliseconds", JSTZDate::setUTCMilliseconds, kJSPropertyAttributeNone},
101     {"setUTCMinutes", JSTZDate::setUTCMinutes, kJSPropertyAttributeNone},
102     {"setUTCMonth", JSTZDate::setUTCMonth, kJSPropertyAttributeNone},
103     {"setUTCSeconds", JSTZDate::setUTCSeconds, kJSPropertyAttributeNone},
104
105     {"getTimezone",          JSTZDate::getTimezone,          kJSPropertyAttributeNone},
106     {"toTimezone",        JSTZDate::toTimezone,        kJSPropertyAttributeNone},
107     {"toLocalTimezone", JSTZDate::toLocalTimezone, kJSPropertyAttributeNone},
108     {"toUTC",           JSTZDate::toUTC,           kJSPropertyAttributeNone},
109
110     {"difference",         JSTZDate::difference,         kJSPropertyAttributeNone},
111     {"equalsTo",        JSTZDate::equalsTo,        kJSPropertyAttributeNone},
112     {"earlierThan",     JSTZDate::earlierThan,     kJSPropertyAttributeNone},
113     {"laterThan",       JSTZDate::laterThan,       kJSPropertyAttributeNone},
114     {"addDuration",     JSTZDate::addDuration,     kJSPropertyAttributeNone},
115
116     {"toLocaleDateString", JSTZDate::toLocaleDateString, kJSPropertyAttributeNone},
117     {"toLocaleTimeString", JSTZDate::toLocaleTimeString, kJSPropertyAttributeNone},
118     {"toLocaleString", JSTZDate::toLocaleString, kJSPropertyAttributeNone},
119     {"toDateString", JSTZDate::toDateString, kJSPropertyAttributeNone},
120     {"toTimeString", JSTZDate::toTimeString, kJSPropertyAttributeNone},
121     {"toString", JSTZDate::toString, kJSPropertyAttributeNone},
122
123     {"getTimezoneAbbreviation", JSTZDate::getTimezoneAbbreviation, kJSPropertyAttributeNone},
124     {"secondsFromUTC", JSTZDate::secondsFromUTC, kJSPropertyAttributeNone},
125     {"isDST", JSTZDate::isDST, kJSPropertyAttributeNone},
126     {"getPreviousDSTTransition", JSTZDate::getPreviousDSTTransition, kJSPropertyAttributeNone},
127     {"getNextDSTTransition", JSTZDate::getNextDSTTransition, kJSPropertyAttributeNone},
128     { 0, 0, 0}
129 };
130
131 JSClassRef JSTZDate::m_jsClassRef = JSClassCreate(JSTZDate::getClassInfo());
132
133 JSObjectRef JSTZDate::createJSObject(JSContextRef context) {
134         LogDebug("entered");
135         ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject();
136         TZDatePrivObject *priv = new TZDatePrivObject(context, TZDate);
137         if (!priv) {
138                 ThrowMsg(NullPointerException, "Can not new an object");
139         }
140
141         return JSObjectMake(context, getClassRef(), priv);
142 }
143
144 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const std::string &timezone) {
145         LogDebug("entered");
146         if (timezone == "")
147                 return createJSObject(context);
148
149         ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject(timezone);
150         TZDatePrivObject *priv = new TZDatePrivObject(context, TZDate);
151         if (!priv) {
152                 ThrowMsg(NullPointerException, "Can not new an object");
153         }
154
155         return JSObjectMake(context, getClassRef(), priv);
156 }
157
158 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const TZDateProperties &properties) {
159         LogDebug("entered");
160         ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject(properties);
161
162         TZDatePrivObject *priv = new TZDatePrivObject(context, TZDate);
163         if (!priv) {
164                 ThrowMsg(NullPointerException, "Can not new an object");
165         }
166
167         return JSObjectMake(context, getClassRef(), priv);
168 }
169
170 JSObjectRef JSTZDate::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) {
171         LogDebug("entered");
172
173         TZDateProperties props;
174         props.year = year;
175         props.month = month;
176         props.day = day;
177         props.hours = hours;
178         props.minutes = minutes;
179         props.seconds = seconds;
180         props.milliseconds = milliseconds;
181         props.timezone = timezone;
182
183         return createJSObject(context, props);
184
185 }
186
187 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const time_t localTime, const std::string &timezone) {
188         LogDebug("entered");
189
190         return createJSObject(context, localTime, 0, timezone);
191 }
192
193 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const time_t localTime, const long msec, const std::string &timezone) {
194         LogDebug("entered");
195
196         struct tm *tm = localtime(&localTime);
197
198         return createJSObject(context, tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, msec, timezone);
199 }
200
201 void JSTZDate::initialize(JSContextRef context, JSObjectRef object)
202 {
203         LogDebug("entered Nothing to do.");
204
205         if (!JSObjectGetPrivate(object)) {
206                 LogDebug("Private object not set... setting it.");
207                 ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject(FALSE);
208                 TZDatePrivObject *priv = new TZDatePrivObject(context, TZDate);
209                 if (!JSObjectSetPrivate(object, priv)) {
210                         delete priv;
211                 }
212         }
213 }
214
215 void JSTZDate::finalize(JSObjectRef object)
216 {
217     LogDebug( "entered" );
218     TZDatePrivObject *priv =
219         static_cast<TZDatePrivObject*>( JSObjectGetPrivate( object ) ) ;
220     delete priv;
221 }
222
223 JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
224 {
225         LogDebug("entered");
226         TZDateProperties prop;
227         TimeUtilConverter converter(ctx);
228
229         TZDatePrivObject* mainPriv = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(constructor));
230         JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
231         Try {
232                 if (argumentCount > 8) {
233                         LogError("Wrong argument count");
234                         ThrowMsg(InvalidArgumentException, "Wrong TZDate argumentCount");
235                 }
236
237                 if (argumentCount == 0) {
238                         return createJSObject(global_context);
239                 } else if (argumentCount <= 2) {
240                         if (!JSValueIsUndefined(ctx, arguments[0])) {
241                                 std::string timezone = "";
242                                 if ((argumentCount == 2) && !JSValueIsNull(ctx, arguments[1])) {
243                                         if (JSValueIsUndefined(ctx, arguments[1]) || !JSValueIsString(ctx, arguments[1]))
244                                                 ThrowMsg(ConversionException, "Argument is invalid");
245                                         timezone = converter.toString(arguments[1]);
246                                 }
247
248                                 if (JSValueIsNull(ctx, arguments[0]))
249                                         return createJSObject(global_context, timezone);
250                                 
251                                 std::time_t date;
252                                 date = converter.toDateTimeT(arguments[0]);
253                                 long msec = 0;
254                                JSStringRef getMillisecondsName = JSStringCreateWithUTF8CString("getMilliseconds");
255                                 JSValueRef getMiliSecFuction = JSObjectGetProperty(ctx, converter.toJSObjectRef(arguments[0]), getMillisecondsName, exception);
256                                 JSStringRelease(getMillisecondsName);
257                                 if (getMiliSecFuction) {
258                                         JSObjectRef function = JSValueToObject(ctx, getMiliSecFuction, exception);
259                                         JSValueRef result = JSObjectCallAsFunction(ctx, function, converter.toJSObjectRef(arguments[0]), 0, NULL, exception);
260                                         msec = converter.toLong(result);
261                                         LogDebug("getMilliseconds = " << msec);
262                                         return createJSObject(global_context, date, msec, timezone);
263                                 }
264                                 return createJSObject(global_context, date, timezone);
265                         }
266                 } else {
267                         prop.year = converter.FromJSValueReftolong(arguments[0]);
268                         prop.month = converter.FromJSValueReftolong(arguments[1]);
269                         prop.day = converter.FromJSValueReftolong(arguments[2]);
270                         if (argumentCount > 3) {
271                                 if (JSValueIsUndefined(ctx, arguments[3]) || !(JSValueIsNumber(ctx, arguments[3]))) {
272                                         ThrowMsg(ConversionException, "Argument is invalid");
273                                 }
274                                 if (!JSValueIsNull(ctx, arguments[3]))
275                                         prop.hours = converter.FromJSValueReftolong(arguments[3]);
276                                 if (argumentCount > 4) {
277                                         if (JSValueIsUndefined(ctx, arguments[4]) || !JSValueIsNumber(ctx, arguments[4])) {
278                                                 ThrowMsg(ConversionException, "Argument is invalid");
279                                         }
280                                         if (!JSValueIsNull(ctx, arguments[4]))
281                                                 prop.minutes = converter.FromJSValueReftolong(arguments[4]);
282                                         if (argumentCount > 5) {
283                                                 if (JSValueIsUndefined(ctx, arguments[5]) || !JSValueIsNumber(ctx, arguments[5])) {
284                                                         ThrowMsg(ConversionException, "Argument is invalid");
285                                                 }
286                                                 if (!JSValueIsNull(ctx, arguments[5]))
287                                                         prop.seconds = converter.FromJSValueReftolong(arguments[5]);
288                                                 if (argumentCount > 6) {
289                                                         if (JSValueIsUndefined(ctx, arguments[6]) || !JSValueIsNumber(ctx, arguments[6])) {
290                                                                 ThrowMsg(ConversionException, "Argument is invalid");
291                                                         }
292                                                         if (!JSValueIsNull(ctx, arguments[6]))
293                                                                 prop.milliseconds= converter.FromJSValueReftolong(arguments[6]);
294                                                         if (argumentCount > 7) {
295                                                                 if (JSValueIsUndefined(ctx, arguments[7]) ||  !JSValueIsString(ctx, arguments[7])) {
296                                                                         ThrowMsg(ConversionException, "Argument is invalid");
297                                                                 }
298                                                                 if (!JSValueIsNull(ctx, arguments[7]))
299                                                                         prop.timezone = converter.toString(arguments[7]);
300                                                         }
301                                                 }
302                                         }
303                                 }
304                         }
305                         return createJSObject(global_context, prop);
306                 }
307                 ThrowMsg(InvalidArgumentException, "Wrong TZDate argumentCount");
308         } Catch(ConversionException) {
309                 LogDebug("Wrong conversion");
310                 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
311                 return NULL;
312         } Catch (InvalidArgumentException) {
313                 LogError("Exception: " << _rethrown_exception.GetMessage());
314                 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
315                 return NULL;
316         } Catch (PlatformException) {
317                 LogError("Exception: " << _rethrown_exception.GetMessage());
318                 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
319                 return NULL;
320         } Catch (WrtDeviceApis::Commons::Exception) {
321                 LogWarning("Trying to get incorrect value");
322                 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
323                 return NULL;
324         }
325         *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
326         return NULL;
327 }
328 const JSClassRef JSTZDate::getClassRef()
329 {
330     if (!m_jsClassRef) {
331             m_jsClassRef = JSClassCreate(&m_classInfo);
332     }
333     return m_jsClassRef;
334 }
335
336 const JSClassDefinition* JSTZDate::getClassInfo()
337 {
338     return &m_classInfo;
339 }
340
341 JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
342         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
343         LogDebug("entered");
344
345         Try {
346                 if (argumentCount != 0) {
347                         LogError("Wrong argument count");
348                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
349                 }
350
351                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
352                 if (!privateObject) {
353                         LogError("Private object is not set.");
354                         ThrowMsg(NullPointerException, "Private object not initialized");
355                 }
356
357                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
358                         privateObject->getContext(),
359                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
360                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
361
362                 ITZDatePtr TZDate(privateObject->getObject());
363                 std::string timezone = TZDate->getTimezone();
364                 TimeUtilConverter converter(context);
365
366                 return converter.toJSValueRef(timezone);
367         } Catch(NullPointerException) {
368                 LogError("Exception: " << _rethrown_exception.GetMessage());
369                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
370         } Catch(UnknownException) {
371                 LogError("Exception: " << _rethrown_exception.GetMessage());
372                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
373         } Catch (InvalidArgumentException) {
374                 LogError("Exception: " << _rethrown_exception.GetMessage());
375                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
376         } Catch (PlatformException) {
377                 LogError("Exception: " << _rethrown_exception.GetMessage());
378                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
379         }
380
381         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
382 }
383
384 JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
385         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
386         LogDebug("entered");
387
388         TimeUtilConverter converter(context);
389
390         Try {
391                 if (argumentCount != 1) {
392                         LogError("Wrong TZDate parameters count");
393                         ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
394                 }
395
396                 if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
397                         || !JSValueIsString(context, arguments[0])) {
398                         LogError("Wrong TZDate parameters");
399                         ThrowMsg(ConversionException, "Wrong TZDate parameters");
400                 }
401
402                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
403                 if (!privateObject) {
404                         LogError("Private object is not set.");
405                         ThrowMsg(NullPointerException, "Private object not initialized");
406                 }
407
408                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
409                         privateObject->getContext(),
410                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
411                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
412
413                 std::string timezone = converter.toString(arguments[0]);
414                 ITZDatePtr TZDate(privateObject->getObject());
415                 return createJSObject(privateObject->getContext(), TZDate->toTimezone(timezone));
416         } Catch(NullPointerException) {
417                 LogError("Exception: " << _rethrown_exception.GetMessage());
418                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
419         } Catch(UnknownException) {
420                 LogError("Exception: " << _rethrown_exception.GetMessage());
421                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
422         } Catch (InvalidArgumentException) {
423                 LogError("Exception: " << _rethrown_exception.GetMessage());
424                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
425         } Catch(ConversionException) {
426                 LogError("Exception: " << _rethrown_exception.GetMessage());
427                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
428         } Catch (PlatformException) {
429                 LogError("Exception: " << _rethrown_exception.GetMessage());
430                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
431         }
432
433         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
434 }
435
436 JSValueRef JSTZDate::diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
437         LogDebug("entered");
438
439         TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
440         if (!privateObject) {
441                 LogError("Private object is not set.");
442                 ThrowMsg(NullPointerException, "Private object not initialized");
443         }
444
445         AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
446                 privateObject->getContext(),
447                 TIMEUTIL_FUNCTION_API_READ_FUNCS);
448
449         TimeUtilConverter converter(context);
450
451         if (argumentCount != 1) {
452                 LogError("Wrong TZDate parameters count");
453                 ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
454         }
455
456         if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
457                 || !JSValueIsObjectOfClass(context, arguments[0], getClassRef())) {
458                 LogError("Wrong TZDate parameters");
459                 ThrowMsg(ConversionException, "Wrong TZDate parameters");
460         }
461
462         TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
463         ITZDatePtr TZDate(privateObject->getObject());
464         long long cmpResult = TZDate->difference(converter.getPropertiesInTZDate(arguments[0]));
465
466         switch (type) {
467                 case EQUALSTO:
468                 {
469                         if (cmpResult == 0)
470                                 return converter.toJSValueRef(TRUE);
471                         else
472                                 return converter.toJSValueRef(FALSE);
473                 }
474                 case EARLIERTHAN:
475                 {
476                         if (cmpResult < 0)
477                                 return converter.toJSValueRef(TRUE);
478                         else
479                                 return converter.toJSValueRef(FALSE);
480                 }
481                 case LATERTHAN:
482                 {
483                         if (cmpResult > 0)
484                                 return converter.toJSValueRef(TRUE);
485                         else
486                                 return converter.toJSValueRef(FALSE);
487                 }
488                 case DIFFERENCE:
489                 default:
490                         return converter.makeMillisecondDurationObject(cmpResult);
491         }
492 }
493
494 JSValueRef JSTZDate::difference(JSContextRef context, JSObjectRef function,
495         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
496         LogDebug("entered");
497
498         Try {
499                 return diffTZDate(context, thisObject, argumentCount,  arguments, exception, DIFFERENCE);
500         } Catch(InvalidArgumentException) {
501                 LogError("Exception: " << _rethrown_exception.GetMessage());
502                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
503         } Catch(NullPointerException) {
504                 LogError("Exception: " << _rethrown_exception.GetMessage());
505                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
506         } Catch(UnknownException) {
507                 LogError("Exception: " << _rethrown_exception.GetMessage());
508                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
509         } Catch(ConversionException) {
510                 LogError("Exception: " << _rethrown_exception.GetMessage());
511                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
512         } Catch (PlatformException) {
513                 LogError("Exception: " << _rethrown_exception.GetMessage());
514                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
515         }
516
517         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
518 }
519
520 JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
521         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
522         LogDebug("entered");
523
524         Try {
525                 return diffTZDate(context, thisObject, argumentCount,  arguments, exception, EQUALSTO);
526         } Catch(NullPointerException) {
527                 LogError("Exception: " << _rethrown_exception.GetMessage());
528                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
529         } Catch(UnknownException) {
530                 LogError("Exception: " << _rethrown_exception.GetMessage());
531                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
532         } Catch (InvalidArgumentException) {
533                 LogError("Exception: " << _rethrown_exception.GetMessage());
534                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
535         } Catch(ConversionException) {
536                 LogError("Exception: " << _rethrown_exception.GetMessage());
537                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
538         } Catch (PlatformException) {
539                 LogError("Exception: " << _rethrown_exception.GetMessage());
540                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
541         }
542         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
543 }
544
545 JSValueRef JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
546         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
547         LogDebug("earlierThan entered");
548
549         Try {
550                 return diffTZDate(context, thisObject, argumentCount,  arguments, exception, EARLIERTHAN);
551         } Catch(NullPointerException) {
552                 LogError("Exception: " << _rethrown_exception.GetMessage());
553                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
554         } Catch(UnknownException) {
555                 LogError("Exception: " << _rethrown_exception.GetMessage());
556                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
557         } Catch (InvalidArgumentException) {
558                 LogError("Exception: " << _rethrown_exception.GetMessage());
559                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
560         } Catch(ConversionException) {
561                 LogError("Exception: " << _rethrown_exception.GetMessage());
562                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
563         } Catch (PlatformException) {
564                 LogError("Exception: " << _rethrown_exception.GetMessage());
565                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
566         }
567         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
568
569 }
570
571 JSValueRef JSTZDate::laterThan(JSContextRef context, JSObjectRef function,
572         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
573
574         LogDebug("laterThan entered");
575
576         Try {
577                 return diffTZDate(context, thisObject, argumentCount,  arguments, exception, LATERTHAN);
578         } Catch(NullPointerException) {
579                 LogError("Exception: " << _rethrown_exception.GetMessage());
580                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
581         } Catch(UnknownException) {
582                 LogError("Exception: " << _rethrown_exception.GetMessage());
583                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
584         } Catch (InvalidArgumentException) {
585                 LogError("Exception: " << _rethrown_exception.GetMessage());
586                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
587         } Catch(ConversionException) {
588                 LogError("Exception: " << _rethrown_exception.GetMessage());
589                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
590         } Catch (PlatformException) {
591                 LogError("Exception: " << _rethrown_exception.GetMessage());
592                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
593         }
594         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
595
596 }
597
598 JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
599         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
600
601         LogDebug("addDuration entered");
602         Try {
603                 if (argumentCount != 1) {
604                         LogError("Wrong argument count");
605                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
606                 }
607
608                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
609                 if (!privateObject) {
610                         LogError("Private object is not set.");
611                         ThrowMsg(NullPointerException, "Private object not initialized");
612                 }
613
614                 TimeUtilConverter converter(context);
615
616                 DurationProperties duration = converter.getDurationPropertis(arguments[0]);
617
618                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
619                         privateObject->getContext(),
620                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
621                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
622
623                 ITZDatePtr TZDate(privateObject->getObject());
624                 TZDateProperties result = TZDate->addDuration(duration);
625                 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
626         } Catch(NullPointerException) {
627                 LogError("Exception: " << _rethrown_exception.GetMessage());
628                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
629         } Catch(UnknownException) {
630                 LogError("Exception: " << _rethrown_exception.GetMessage());
631                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
632         } Catch (InvalidArgumentException) {
633                 LogError("Exception: " << _rethrown_exception.GetMessage());
634                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
635         } Catch(ConversionException) {
636                 LogError("Exception: " << _rethrown_exception.GetMessage());
637                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
638         } Catch (PlatformException) {
639                 LogError("Exception: " << _rethrown_exception.GetMessage());
640                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
641         }
642         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
643 }
644
645 JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
646         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
647
648         LogDebug("toUTC entered");
649         Try {
650                 if (argumentCount != 0) {
651                         LogError("Wrong argument count");
652                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
653                 }
654
655                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
656                 if (!privateObject) {
657                         LogError("Private object is not set.");
658                         ThrowMsg(NullPointerException, "Private object not initialized");
659                 }
660
661                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
662                         privateObject->getContext(),
663                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
664                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
665
666                 ITZDatePtr TZDate(privateObject->getObject());
667                 TZDateProperties result = TZDate->toUTC();
668                 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
669         } Catch(NullPointerException) {
670                 LogError("Exception: " << _rethrown_exception.GetMessage());
671                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
672         } Catch(UnknownException) {
673                 LogError("Exception: " << _rethrown_exception.GetMessage());
674                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
675         } Catch (InvalidArgumentException) {
676                 LogError("Exception: " << _rethrown_exception.GetMessage());
677                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
678         } Catch (PlatformException) {
679                 LogError("Exception: " << _rethrown_exception.GetMessage());
680                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
681         }
682         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
683 }
684
685
686 JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
687         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
688
689         LogDebug("toLocalTimezone entered");
690         Try {
691                 if (argumentCount != 0) {
692                         LogError("Wrong argument count");
693                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
694                 }
695
696                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
697                 if (!privateObject) {
698                         LogError("Private object is not set.");
699                         ThrowMsg(NullPointerException, "Private object not initialized");
700                 }
701
702                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
703                         privateObject->getContext(),
704                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
705                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
706
707                 ITZDatePtr TZDate(privateObject->getObject());
708                 TZDateProperties result = TZDate->toLocalTimezone();
709                 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
710         } Catch(NullPointerException) {
711                 LogError("Exception: " << _rethrown_exception.GetMessage());
712                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
713         } Catch(UnknownException) {
714                 LogError("Exception: " << _rethrown_exception.GetMessage());
715                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
716         } Catch (InvalidArgumentException) {
717                 LogError("Exception: " << _rethrown_exception.GetMessage());
718                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
719         } Catch (PlatformException) {
720                 LogError("Exception: " << _rethrown_exception.GetMessage());
721                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
722         }
723         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
724 }
725
726 JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef function,
727         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
728         LogDebug("Entered");
729         Try {
730                 if (argumentCount != 0) {
731                         LogError("Wrong argument count");
732                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
733                 }
734
735                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
736                 if (!privateObject) {
737                         LogError("Private object is not set.");
738                         ThrowMsg(NullPointerException, "Private object not initialized");
739                 }
740
741                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
742                         privateObject->getContext(),
743                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
744                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
745
746                 TimeUtilConverter converter(context);
747
748                 ITZDatePtr TZDate(privateObject->getObject());
749                 std::string result = TZDate->toDateString(true);
750                 return converter.toJSValueRef(result);
751         } Catch(NullPointerException) {
752                 LogError("Exception: " << _rethrown_exception.GetMessage());
753                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
754         } Catch(UnknownException) {
755                 LogError("Exception: " << _rethrown_exception.GetMessage());
756                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
757         } Catch (InvalidArgumentException) {
758                 LogError("Exception: " << _rethrown_exception.GetMessage());
759                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
760         } Catch (PlatformException) {
761                 LogError("Exception: " << _rethrown_exception.GetMessage());
762                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
763         }
764
765         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
766 }
767
768 JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef function,
769         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
770         LogDebug("Entered");
771         Try {
772                 if (argumentCount != 0) {
773                         LogError("Wrong argument count");
774                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
775                 }
776
777                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
778                 if (!privateObject) {
779                         LogError("Private object is not set.");
780                         ThrowMsg(NullPointerException, "Private object not initialized");
781                 }
782
783                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
784                         privateObject->getContext(),
785                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
786                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
787
788                 TimeUtilConverter converter(context);
789
790                 ITZDatePtr TZDate(privateObject->getObject());
791                 std::string result = TZDate->toTimeString(true);
792                 return converter.toJSValueRef(result);
793         } Catch(NullPointerException) {
794                 LogError("Exception: " << _rethrown_exception.GetMessage());
795                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
796         } Catch(UnknownException) {
797                 LogError("Exception: " << _rethrown_exception.GetMessage());
798                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
799         } Catch (InvalidArgumentException) {
800                 LogError("Exception: " << _rethrown_exception.GetMessage());
801                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
802         } Catch (PlatformException) {
803                 LogError("Exception: " << _rethrown_exception.GetMessage());
804                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
805         }
806
807         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
808 }
809
810 JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
811         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
812         LogDebug("Entered");
813         Try {
814                 if (argumentCount != 0) {
815                         LogError("Wrong argument count");
816                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
817                 }
818
819                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
820                 if (!privateObject) {
821                         LogError("Private object is not set.");
822                         ThrowMsg(NullPointerException, "Private object not initialized");
823                 }
824
825                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
826                         privateObject->getContext(),
827                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
828                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
829
830                 TimeUtilConverter converter(context);
831
832                 ITZDatePtr TZDate(privateObject->getObject());
833                 std::string result = TZDate->toString(true);
834                 return converter.toJSValueRef(result);
835         } Catch(NullPointerException) {
836                 LogError("Exception: " << _rethrown_exception.GetMessage());
837                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
838         } Catch(UnknownException) {
839                 LogError("Exception: " << _rethrown_exception.GetMessage());
840                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
841         } Catch (InvalidArgumentException) {
842                 LogError("Exception: " << _rethrown_exception.GetMessage());
843                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
844         } Catch (PlatformException) {
845                 LogError("Exception: " << _rethrown_exception.GetMessage());
846                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
847         }
848
849         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
850 }
851
852 JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
853         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
854         LogDebug("Entered");
855         Try {
856                 if (argumentCount != 0) {
857                         LogError("Wrong argument count");
858                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
859                 }
860
861                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
862                 if (!privateObject) {
863                         LogError("Private object is not set.");
864                         ThrowMsg(NullPointerException, "Private object not initialized");
865                 }
866
867                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
868                         privateObject->getContext(),
869                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
870                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
871
872                 TimeUtilConverter converter(context);
873
874                 ITZDatePtr TZDate(privateObject->getObject());
875                 std::string result = TZDate->toDateString();
876                 return converter.toJSValueRef(result);
877         } Catch(NullPointerException) {
878                 LogError("Exception: " << _rethrown_exception.GetMessage());
879                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
880         } Catch(UnknownException) {
881                 LogError("Exception: " << _rethrown_exception.GetMessage());
882                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
883         } Catch (InvalidArgumentException) {
884                 LogError("Exception: " << _rethrown_exception.GetMessage());
885                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
886         } Catch (PlatformException) {
887                 LogError("Exception: " << _rethrown_exception.GetMessage());
888                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
889         }
890
891         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
892 }
893
894 JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
895         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
896         LogDebug("Entered");
897         Try {
898                 if (argumentCount != 0) {
899                         LogError("Wrong argument count");
900                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
901                 }
902
903                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
904                 if (!privateObject) {
905                         LogError("Private object is not set.");
906                         ThrowMsg(NullPointerException, "Private object not initialized");
907                 }
908
909                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
910                         privateObject->getContext(),
911                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
912                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
913
914                 TimeUtilConverter converter(context);
915
916                 ITZDatePtr TZDate(privateObject->getObject());
917                 std::string result = TZDate->toTimeString();
918                 return converter.toJSValueRef(result);
919         } Catch(NullPointerException) {
920                 LogError("Exception: " << _rethrown_exception.GetMessage());
921                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
922         } Catch(UnknownException) {
923                 LogError("Exception: " << _rethrown_exception.GetMessage());
924                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
925         } Catch (InvalidArgumentException) {
926                 LogError("Exception: " << _rethrown_exception.GetMessage());
927                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
928         } Catch (PlatformException) {
929                 LogError("Exception: " << _rethrown_exception.GetMessage());
930                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
931         }
932
933         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
934 }
935
936
937 JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
938         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
939         LogDebug("Entered");
940         Try {
941                 if (argumentCount != 0) {
942                         LogError("Wrong argument count");
943                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
944                 }
945
946                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
947                 if (!privateObject) {
948                         LogError("Private object is not set.");
949                         ThrowMsg(NullPointerException, "Private object not initialized");
950                 }
951
952                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
953                         privateObject->getContext(),
954                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
955                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
956
957                 TimeUtilConverter converter(context);
958
959                 ITZDatePtr TZDate(privateObject->getObject());
960                 std::string result = TZDate->toString();
961                 return converter.toJSValueRef(result);
962         } Catch(NullPointerException) {
963                 LogError("Exception: " << _rethrown_exception.GetMessage());
964                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
965         } Catch(UnknownException) {
966                 LogError("Exception: " << _rethrown_exception.GetMessage());
967                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
968         } Catch (InvalidArgumentException) {
969                 LogError("Exception: " << _rethrown_exception.GetMessage());
970                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
971         } Catch (PlatformException) {
972                 LogError("Exception: " << _rethrown_exception.GetMessage());
973                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
974         }
975
976         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
977 }
978
979 JSValueRef JSTZDate::getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
980         JSValueRef * exception) {
981         LogDebug("<<<");
982
983         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
984         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
985 } //getDate()
986
987 JSValueRef JSTZDate::getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
988         JSValueRef * exception) {
989         LogDebug("<<<");
990
991         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DAY_OF_WEEK;
992         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
993 } //getDay()
994
995 JSValueRef JSTZDate::getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
996         JSValueRef * exception) {
997         LogDebug("<<<");
998
999         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
1000         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1001 } //getFullYear()
1002
1003 JSValueRef JSTZDate::getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1004         JSValueRef * exception) {
1005         LogDebug("<<<");
1006
1007         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
1008         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1009 } //getHours()
1010
1011 JSValueRef JSTZDate::getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1012         JSValueRef * exception) {
1013         LogDebug("<<<");
1014
1015         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
1016         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1017 } //getMilliseconds()
1018
1019 JSValueRef JSTZDate::getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1020         JSValueRef * exception) {
1021         LogDebug("<<<");
1022
1023         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
1024         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1025 } //getMinutes()
1026
1027 JSValueRef JSTZDate::getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1028         JSValueRef * exception) {
1029         LogDebug("<<<");
1030         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
1031         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1032 } //getMonth()
1033
1034 JSValueRef JSTZDate::getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1035         JSValueRef * exception) {
1036         LogDebug("<<<");
1037
1038         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
1039         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1040 } //getSeconds()
1041
1042 JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
1043         ITZDate::TZDateFields dateFields) {
1044         try {
1045                 if (argumentCount != 0) {
1046                         LogError("Wrong argument count");
1047                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1048                 }
1049
1050                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1051
1052                 if (privateObject == NULL) {
1053                         LogError(">>> NULL Exception");
1054                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1055                 }
1056
1057                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1058                         privateObject->getContext(),
1059                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1060                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1061
1062                 ITZDatePtr tzDate(privateObject->getObject());
1063                 long retVal = tzDate->get(dateFields);
1064
1065                 TimeUtilConverter converter(context);
1066                 LogDebug(">>> retVal:" << retVal);
1067                 return converter.toJSValueRef(static_cast<int> (retVal));
1068         } Catch(NullPointerException) {
1069                 LogError("Exception: " << _rethrown_exception.GetMessage());
1070                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1071         } Catch(UnknownException) {
1072                 LogError("Exception: " << _rethrown_exception.GetMessage());
1073                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1074         } Catch (InvalidArgumentException) {
1075                 LogError("Exception: " << _rethrown_exception.GetMessage());
1076                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1077         } Catch (PlatformException) {
1078                 LogError("Exception: " << _rethrown_exception.GetMessage());
1079                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1080         }
1081
1082         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1083 }
1084
1085 JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1086         JSValueRef * exception) {
1087         LogDebug("<<<");
1088
1089         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
1090
1091         try{
1092                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1093         } Catch(NullPointerException) {
1094                 LogError("Exception: " << _rethrown_exception.GetMessage());
1095                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1096         } Catch(UnknownException) {
1097                 LogError("Exception: " << _rethrown_exception.GetMessage());
1098                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1099         } Catch (InvalidArgumentException) {
1100                 LogError("Exception: " << _rethrown_exception.GetMessage());
1101                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1102         } Catch(ConversionException) {
1103                 LogError("Exception: " << _rethrown_exception.GetMessage());
1104                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1105         } Catch (PlatformException) {
1106                 LogError("Exception: " << _rethrown_exception.GetMessage());
1107                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1108         }
1109
1110         return JSValueMakeNull(context);
1111 } //setDate()
1112
1113 JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1114         JSValueRef * exception) {
1115         LogDebug("<<<");
1116
1117         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
1118
1119         try{
1120                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1121         } Catch(NullPointerException) {
1122                 LogError("Exception: " << _rethrown_exception.GetMessage());
1123                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1124         } Catch(UnknownException) {
1125                 LogError("Exception: " << _rethrown_exception.GetMessage());
1126                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1127         } Catch (InvalidArgumentException) {
1128                 LogError("Exception: " << _rethrown_exception.GetMessage());
1129                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1130         } Catch(ConversionException) {
1131                 LogError("Exception: " << _rethrown_exception.GetMessage());
1132                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1133         } Catch (PlatformException) {
1134                 LogError("Exception: " << _rethrown_exception.GetMessage());
1135                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1136         }
1137
1138         return JSValueMakeNull(context);
1139 } //setFullYear()
1140
1141 JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1142         JSValueRef * exception) {
1143         LogDebug("<<<");
1144
1145         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
1146
1147         Try {
1148                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1149         } Catch(NullPointerException) {
1150                 LogError("Exception: " << _rethrown_exception.GetMessage());
1151                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1152         } Catch(UnknownException) {
1153                 LogError("Exception: " << _rethrown_exception.GetMessage());
1154                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1155         } Catch (InvalidArgumentException) {
1156                 LogError("Exception: " << _rethrown_exception.GetMessage());
1157                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1158         } Catch(ConversionException) {
1159                 LogError("Exception: " << _rethrown_exception.GetMessage());
1160                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1161         } Catch (PlatformException) {
1162                 LogError("Exception: " << _rethrown_exception.GetMessage());
1163                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1164         }
1165
1166         return JSValueMakeNull(context);
1167 } //setHours()
1168
1169 JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1170         JSValueRef * exception) {
1171         LogDebug("<<<");
1172
1173         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
1174         
1175         Try{
1176                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1177         } Catch(NullPointerException) {
1178                 LogError("Exception: " << _rethrown_exception.GetMessage());
1179                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1180         } Catch(UnknownException) {
1181                 LogError("Exception: " << _rethrown_exception.GetMessage());
1182                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1183         } Catch (InvalidArgumentException) {
1184                 LogError("Exception: " << _rethrown_exception.GetMessage());
1185                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1186         } Catch(ConversionException) {
1187                 LogError("Exception: " << _rethrown_exception.GetMessage());
1188                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1189         } Catch (PlatformException) {
1190                 LogError("Exception: " << _rethrown_exception.GetMessage());
1191                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1192         }
1193
1194         return JSValueMakeNull(context);
1195 } //setMilliseconds()
1196
1197 JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1198         JSValueRef * exception) {
1199         LogDebug("<<<");
1200
1201         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
1202
1203         Try {
1204                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1205         } Catch(NullPointerException) {
1206                 LogError("Exception: " << _rethrown_exception.GetMessage());
1207                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1208         } Catch(UnknownException) {
1209                 LogError("Exception: " << _rethrown_exception.GetMessage());
1210                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1211         } Catch (InvalidArgumentException) {
1212                 LogError("Exception: " << _rethrown_exception.GetMessage());
1213                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1214         } Catch(ConversionException) {
1215                 LogError("Exception: " << _rethrown_exception.GetMessage());
1216                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1217         } Catch (PlatformException) {
1218                 LogError("Exception: " << _rethrown_exception.GetMessage());
1219                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1220         }
1221
1222         return JSValueMakeNull(context);
1223 } //setMinutes()
1224
1225 JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1226         JSValueRef * exception) {
1227         LogDebug("<<<");
1228
1229         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
1230
1231         Try {
1232                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1233         } Catch(NullPointerException) {
1234                 LogError("Exception: " << _rethrown_exception.GetMessage());
1235                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1236         } Catch(UnknownException) {
1237                 LogError("Exception: " << _rethrown_exception.GetMessage());
1238                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1239         } Catch (InvalidArgumentException) {
1240                 LogError("Exception: " << _rethrown_exception.GetMessage());
1241                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1242         } Catch(ConversionException) {
1243                 LogError("Exception: " << _rethrown_exception.GetMessage());
1244                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1245         } Catch (PlatformException) {
1246                 LogError("Exception: " << _rethrown_exception.GetMessage());
1247                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1248         }
1249
1250         return JSValueMakeNull(context);
1251 } //setMonth()
1252
1253 JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1254         JSValueRef * exception) {
1255         LogDebug("<<<");
1256
1257         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
1258
1259         Try {
1260                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1261         } Catch(NullPointerException) {
1262                 LogError("Exception: " << _rethrown_exception.GetMessage());
1263                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1264         } Catch(UnknownException) {
1265                 LogError("Exception: " << _rethrown_exception.GetMessage());
1266                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1267         } Catch (InvalidArgumentException) {
1268                 LogError("Exception: " << _rethrown_exception.GetMessage());
1269                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1270         } Catch(ConversionException) {
1271                 LogError("Exception: " << _rethrown_exception.GetMessage());
1272                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1273         } Catch (PlatformException) {
1274                 LogError("Exception: " << _rethrown_exception.GetMessage());
1275                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1276         }
1277
1278         return JSValueMakeNull(context);
1279 } //setSeconds()
1280
1281
1282 JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1283         JSValueRef * exception, ITZDate::TZDateFields dateFields) {
1284
1285         if (argumentCount != 1) {
1286                 LogError("Wrong parameters");
1287                 ThrowMsg(InvalidArgumentException, "argumentIndex is bigger than argumentCount");
1288         }
1289
1290         TimeUtilConverter converter(context);
1291
1292         if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
1293                 || (!JSValueIsNumber(context, arguments[0])))
1294                 ThrowMsg(ConversionException, "Invalid Argument");
1295
1296         int data = converter.toInt(arguments[0]);
1297
1298         if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
1299                 ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1300
1301         TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1302
1303         if (privateObject == NULL) {
1304                 LogError(">>> NULL Exception");
1305                 ThrowMsg(UnknownException, "privateObject is NULL");
1306         }
1307
1308         AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1309                 privateObject->getContext(),
1310                 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1311         TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1312
1313         ITZDatePtr tzDate(privateObject->getObject());
1314         tzDate->set(dateFields, static_cast<long> (data));
1315
1316         return JSValueMakeNull(context);
1317 }       //setTZDateValue
1318
1319 JSValueRef JSTZDate::getUTCDate(JSContextRef context, JSObjectRef function,
1320         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1321         LogDebug("Entered");
1322         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_DATE, exception);
1323 }
1324
1325 JSValueRef JSTZDate::getUTCDay(JSContextRef context, JSObjectRef function,
1326         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1327         LogDebug("Entered");
1328         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_DAY_OF_WEEK, exception);
1329 }
1330
1331 JSValueRef JSTZDate::getUTCFullYear(JSContextRef context, JSObjectRef function,
1332         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1333         LogDebug("Entered");
1334         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_YEAR, exception);
1335 }
1336
1337 JSValueRef JSTZDate::getUTCHours(JSContextRef context, JSObjectRef function,
1338         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1339         LogDebug("Entered");
1340         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_HOUR_OF_DAY, exception);
1341 }
1342
1343 JSValueRef JSTZDate::getUTCMilliseconds(JSContextRef context, JSObjectRef function,
1344         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1345         LogDebug("Entered");
1346         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MILLISECOND, exception);
1347 }
1348
1349 JSValueRef JSTZDate::getUTCMinutes(JSContextRef context, JSObjectRef function,
1350         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1351         LogDebug("Entered");
1352         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MINUTE, exception);
1353 }
1354
1355 JSValueRef JSTZDate::getUTCMonth(JSContextRef context, JSObjectRef function,
1356         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1357         LogDebug("Entered");
1358         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MONTH, exception);
1359 }
1360
1361 JSValueRef JSTZDate::getUTCSeconds(JSContextRef context, JSObjectRef function,
1362         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1363         LogDebug("Entered");
1364         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_SECOND, exception);
1365 }
1366
1367 JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, ITZDate::TZDateFields DateFields, JSValueRef * exception) {
1368         LogDebug("Entered");
1369         Try {
1370                 if (argumentCount != 0) {
1371                         LogError("Wrong argument count");
1372                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1373                 }
1374
1375                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1376                 if (!privateObject) {
1377                         LogError("Private object is not set.");
1378                         ThrowMsg(NullPointerException, "Private object not initialized");
1379                 }
1380
1381                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1382                         privateObject->getContext(),
1383                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1384                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1385
1386                 TimeUtilConverter converter(context);
1387
1388                 ITZDatePtr TZDate(privateObject->getObject());
1389                 long result = TZDate->getUTC(DateFields);
1390
1391                 return converter.toJSValueRefLong(result);
1392         } Catch(NullPointerException) {
1393                 LogError("Exception: " << _rethrown_exception.GetMessage());
1394                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1395         } Catch(UnknownException) {
1396                 LogError("Exception: " << _rethrown_exception.GetMessage());
1397                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1398         } Catch (InvalidArgumentException) {
1399                 LogError("Exception: " << _rethrown_exception.GetMessage());
1400                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1401         } Catch (PlatformException) {
1402                 LogError("Exception: " << _rethrown_exception.GetMessage());
1403                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1404         }
1405
1406         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1407 }
1408
1409 JSValueRef JSTZDate::setUTCDate(JSContextRef context, JSObjectRef function,
1410         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1411         LogDebug("Entered");
1412
1413         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_DATE, exception);
1414 }
1415
1416 JSValueRef JSTZDate::setUTCFullYear(JSContextRef context, JSObjectRef function,
1417         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1418         LogDebug("Entered");
1419
1420         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_YEAR, exception);
1421 }
1422
1423 JSValueRef JSTZDate::setUTCHours(JSContextRef context, JSObjectRef function,
1424         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1425         LogDebug("Entered");
1426
1427         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_HOUR_OF_DAY, exception);
1428 }
1429
1430 JSValueRef JSTZDate::setUTCMilliseconds(JSContextRef context, JSObjectRef function,
1431         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1432         LogDebug("Entered");
1433
1434         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MILLISECOND, exception);
1435 }
1436
1437 JSValueRef JSTZDate::setUTCMinutes(JSContextRef context, JSObjectRef function,
1438         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1439         LogDebug("Entered");
1440
1441         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MINUTE, exception);
1442 }
1443
1444 JSValueRef JSTZDate::setUTCMonth(JSContextRef context, JSObjectRef function,
1445         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1446         LogDebug("Entered");
1447
1448         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MONTH, exception);
1449 }
1450
1451 JSValueRef JSTZDate::setUTCSeconds(JSContextRef context, JSObjectRef function,
1452         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1453         LogDebug("Entered");
1454
1455         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_SECOND, exception);
1456 }
1457
1458 JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject,
1459         size_t argumentCount, const JSValueRef arguments[], ITZDate::TZDateFields dateFields, JSValueRef * exception) {
1460         LogDebug("Entered");
1461         Try {
1462                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1463                 if (!privateObject) {
1464                         LogError("Private object is not set.");
1465                         ThrowMsg(NullPointerException, "Private object not initialized");
1466                 }
1467
1468                 if (argumentCount != 1) {
1469                         LogError("Wrong TZDate parameters count");
1470                         ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
1471                 }
1472                         
1473                 if (!JSValueIsNumber(context, arguments[0]))
1474                 {
1475                         LogError("Wrong TZDate parameters");
1476                         ThrowMsg(ConversionException, "Wrong TZDate parameters");
1477                 }
1478
1479                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1480                         privateObject->getContext(),
1481                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1482                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1483
1484                 TimeUtilConverter converter(context);
1485                 
1486                 long data = converter.FromJSValueReftolong(arguments[0]);
1487
1488                 if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
1489                         ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1490         
1491                 ITZDatePtr TZDate(privateObject->getObject());
1492                 TZDate->setUTC(dateFields, data);
1493
1494                 return JSValueMakeNull(context);
1495         } Catch(NullPointerException) {
1496                 LogError("Exception: " << _rethrown_exception.GetMessage());
1497                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1498         } Catch(UnknownException) {
1499                 LogError("Exception: " << _rethrown_exception.GetMessage());
1500                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1501         } Catch (InvalidArgumentException) {
1502                 LogError("Exception: " << _rethrown_exception.GetMessage());
1503                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1504         } Catch(ConversionException) {
1505                 LogError("Exception: " << _rethrown_exception.GetMessage());
1506                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1507         } Catch (PlatformException) {
1508                 LogError("Exception: " << _rethrown_exception.GetMessage());
1509                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1510         }
1511
1512         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1513 }
1514
1515 JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1516         LogDebug("entered");
1517         Try {
1518                 if (argumentCount != 0) {
1519                         LogError("Wrong argument count");
1520                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1521                 }
1522
1523                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1524                 if (!privateObject) {
1525                         LogError("Private object is not set.");
1526                         ThrowMsg(NullPointerException, "Private object not initialized");
1527                 }
1528
1529                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1530                         privateObject->getContext(),
1531                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1532                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1533
1534                 TimeUtilConverter converter(context);
1535
1536                 ITZDatePtr tzDate(privateObject->getObject());
1537
1538                 std::string result;
1539
1540                 return converter.toJSValueRef(tzDate->getTimezoneAbbreviation());
1541         } Catch(NullPointerException) {
1542                 LogError("Exception: " << _rethrown_exception.GetMessage());
1543                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1544         } Catch(UnknownException) {
1545                 LogError("Exception: " << _rethrown_exception.GetMessage());
1546                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1547         } Catch (InvalidArgumentException) {
1548                 LogError("Exception: " << _rethrown_exception.GetMessage());
1549                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1550         } Catch (PlatformException) {
1551                 LogError("Exception: " << _rethrown_exception.GetMessage());
1552                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1553         }
1554         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1555 }
1556
1557 JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1558         LogDebug("entered");
1559
1560         Try {
1561                 if (argumentCount != 0) {
1562                         LogError("Wrong argument count");
1563                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1564                 }
1565
1566                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1567                 if (!privateObject) {
1568                         LogError("Private object is not set.");
1569                         ThrowMsg(NullPointerException, "Private object not initialized");
1570                 }
1571
1572                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1573                         privateObject->getContext(),
1574                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1575                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1576
1577                 TimeUtilConverter converter(context);
1578
1579                 ITZDatePtr tzDate(privateObject->getObject());
1580
1581                 return converter.toJSValueRefLong(tzDate->secondsFromUTC());
1582         } Catch(NullPointerException) {
1583                 LogError("Exception: " << _rethrown_exception.GetMessage());
1584                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1585         } Catch(UnknownException) {
1586                 LogError("Exception: " << _rethrown_exception.GetMessage());
1587                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1588         } Catch (InvalidArgumentException) {
1589                 LogError("Exception: " << _rethrown_exception.GetMessage());
1590                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1591         } Catch (PlatformException) {
1592                 LogError("Exception: " << _rethrown_exception.GetMessage());
1593                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1594         }
1595         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1596 }
1597 JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1598         LogDebug("entered");
1599         Try {
1600                 if (argumentCount != 0) {
1601                         LogError("Wrong argument count");
1602                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1603                 }
1604
1605                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1606                 if (!privateObject) {
1607                         LogError("Private object is not set.");
1608                         ThrowMsg(NullPointerException, "Private object not initialized");
1609                 }
1610
1611                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1612                         privateObject->getContext(),
1613                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1614                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1615
1616                 TimeUtilConverter converter(context);
1617
1618                 ITZDatePtr tzDate(privateObject->getObject());
1619
1620                 return converter.toJSValueRef(tzDate->isDST());
1621         } Catch(NullPointerException) {
1622                 LogError("Exception: " << _rethrown_exception.GetMessage());
1623                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1624         } Catch(UnknownException) {
1625                 LogError("Exception: " << _rethrown_exception.GetMessage());
1626                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1627         } Catch (InvalidArgumentException) {
1628                 LogError("Exception: " << _rethrown_exception.GetMessage());
1629                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1630         } Catch (PlatformException) {
1631                 LogError("Exception: " << _rethrown_exception.GetMessage());
1632                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1633         }
1634         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1635 }
1636
1637 JSValueRef JSTZDate::getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1638         LogDebug("entered");
1639
1640         Try {
1641                 if (argumentCount != 0) {
1642                         LogError("Wrong argument count");
1643                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1644                 }
1645
1646                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1647                 if (!privateObject) {
1648                         LogError("Private object is not set.");
1649                         ThrowMsg(NullPointerException, "Private object not initialized");
1650                 }
1651
1652                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1653                         privateObject->getContext(),
1654                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1655                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1656                 
1657                 TimeUtilConverter converter(context);
1658
1659                 ITZDatePtr tzDate(privateObject->getObject());
1660
1661                 return createJSObject(privateObject->getContext(), tzDate->getDSTTransition(ITZDate::PREV_TRANSITION));
1662         } Catch(NullPointerException) {
1663                 LogError("Exception: " << _rethrown_exception.GetMessage());
1664                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1665         } Catch(UnknownException) {
1666                 LogError("Exception: " << _rethrown_exception.GetMessage());
1667                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1668         } Catch (InvalidArgumentException) {
1669                 LogError("Exception: " << _rethrown_exception.GetMessage());
1670                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1671         } Catch (PlatformException) {
1672                 LogError("Exception: " << _rethrown_exception.GetMessage());
1673                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1674         }
1675         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1676 }
1677
1678 JSValueRef JSTZDate::getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1679         LogDebug("entered");
1680
1681         Try {
1682                 if (argumentCount != 0) {
1683                         LogError("Wrong argument count");
1684                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1685                 }
1686
1687                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1688                 if (!privateObject) {
1689                         LogError("Private object is not set.");
1690                         ThrowMsg(NullPointerException, "Private object not initialized");
1691                 }
1692
1693                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1694                         privateObject->getContext(),
1695                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1696                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1697                 
1698                 TimeUtilConverter converter(context);
1699
1700                 ITZDatePtr tzDate(privateObject->getObject());
1701
1702                 return createJSObject(privateObject->getContext(), tzDate->getDSTTransition(ITZDate::NEXT_TRANSITION));
1703         } Catch(NullPointerException) {
1704                 LogError("Exception: " << _rethrown_exception.GetMessage());
1705                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1706         } Catch(UnknownException) {
1707                 LogError("Exception: " << _rethrown_exception.GetMessage());
1708                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1709         } Catch (InvalidArgumentException) {
1710                 LogError("Exception: " << _rethrown_exception.GetMessage());
1711                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1712         } Catch (PlatformException) {
1713                 LogError("Exception: " << _rethrown_exception.GetMessage());
1714                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1715         }
1716         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1717 }
1718
1719 }               //Tizen1_0
1720 }               //TizenApis
1721 #undef min