Beta merge 2
[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     hasInstance, //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 bool JSTZDate::hasInstance(JSContextRef context,
342         JSObjectRef constructor,
343         JSValueRef possibleInstance,
344         JSValueRef* exception)
345 {
346     return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
347 }
348
349 JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
350         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
351         LogDebug("entered");
352
353         Try {
354                 if (argumentCount != 0) {
355                         LogError("Wrong argument count");
356                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
357                 }
358
359                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
360                 if (!privateObject) {
361                         LogError("Private object is not set.");
362                         ThrowMsg(NullPointerException, "Private object not initialized");
363                 }
364
365                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
366                         privateObject->getContext(),
367                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
368                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
369
370                 ITZDatePtr TZDate(privateObject->getObject());
371                 std::string timezone = TZDate->getTimezone();
372                 TimeUtilConverter converter(context);
373
374                 return converter.toJSValueRef(timezone);
375         } Catch(NullPointerException) {
376                 LogError("Exception: " << _rethrown_exception.GetMessage());
377                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
378         } Catch(UnknownException) {
379                 LogError("Exception: " << _rethrown_exception.GetMessage());
380                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
381         } Catch (InvalidArgumentException) {
382                 LogError("Exception: " << _rethrown_exception.GetMessage());
383                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
384         } Catch (PlatformException) {
385                 LogError("Exception: " << _rethrown_exception.GetMessage());
386                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
387         }
388
389         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
390 }
391
392 JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
393         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
394         LogDebug("entered");
395
396         TimeUtilConverter converter(context);
397
398         Try {
399                 if (argumentCount != 1) {
400                         LogError("Wrong TZDate parameters count");
401                         ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
402                 }
403
404                 if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
405                         || !JSValueIsString(context, arguments[0])) {
406                         LogError("Wrong TZDate parameters");
407                         ThrowMsg(ConversionException, "Wrong TZDate parameters");
408                 }
409
410                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
411                 if (!privateObject) {
412                         LogError("Private object is not set.");
413                         ThrowMsg(NullPointerException, "Private object not initialized");
414                 }
415
416                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
417                         privateObject->getContext(),
418                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
419                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
420
421                 std::string timezone = converter.toString(arguments[0]);
422                 ITZDatePtr TZDate(privateObject->getObject());
423                 return createJSObject(privateObject->getContext(), TZDate->toTimezone(timezone));
424         } Catch(NullPointerException) {
425                 LogError("Exception: " << _rethrown_exception.GetMessage());
426                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
427         } Catch(UnknownException) {
428                 LogError("Exception: " << _rethrown_exception.GetMessage());
429                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
430         } Catch (InvalidArgumentException) {
431                 LogError("Exception: " << _rethrown_exception.GetMessage());
432                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
433         } Catch(ConversionException) {
434                 LogError("Exception: " << _rethrown_exception.GetMessage());
435                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
436         } Catch (PlatformException) {
437                 LogError("Exception: " << _rethrown_exception.GetMessage());
438                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
439         }
440
441         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
442 }
443
444 JSValueRef JSTZDate::diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
445         LogDebug("entered");
446
447         TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
448         if (!privateObject) {
449                 LogError("Private object is not set.");
450                 ThrowMsg(NullPointerException, "Private object not initialized");
451         }
452
453         AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
454                 privateObject->getContext(),
455                 TIMEUTIL_FUNCTION_API_READ_FUNCS);
456
457         TimeUtilConverter converter(context);
458
459         if (argumentCount != 1) {
460                 LogError("Wrong TZDate parameters count");
461                 ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
462         }
463
464         if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
465                 || !JSValueIsObjectOfClass(context, arguments[0], getClassRef())) {
466                 LogError("Wrong TZDate parameters");
467                 ThrowMsg(ConversionException, "Wrong TZDate parameters");
468         }
469
470         TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
471         ITZDatePtr TZDate(privateObject->getObject());
472         long long cmpResult = TZDate->difference(converter.getPropertiesInTZDate(arguments[0]));
473
474         switch (type) {
475                 case EQUALSTO:
476                 {
477                         if (cmpResult == 0)
478                                 return converter.toJSValueRef(TRUE);
479                         else
480                                 return converter.toJSValueRef(FALSE);
481                 }
482                 case EARLIERTHAN:
483                 {
484                         if (cmpResult < 0)
485                                 return converter.toJSValueRef(TRUE);
486                         else
487                                 return converter.toJSValueRef(FALSE);
488                 }
489                 case LATERTHAN:
490                 {
491                         if (cmpResult > 0)
492                                 return converter.toJSValueRef(TRUE);
493                         else
494                                 return converter.toJSValueRef(FALSE);
495                 }
496                 case DIFFERENCE:
497                 default:
498                         return converter.makeMillisecondDurationObject(cmpResult);
499         }
500 }
501
502 JSValueRef JSTZDate::difference(JSContextRef context, JSObjectRef function,
503         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
504         LogDebug("entered");
505
506         Try {
507                 return diffTZDate(context, thisObject, argumentCount,  arguments, exception, DIFFERENCE);
508         } Catch(InvalidArgumentException) {
509                 LogError("Exception: " << _rethrown_exception.GetMessage());
510                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
511         } Catch(NullPointerException) {
512                 LogError("Exception: " << _rethrown_exception.GetMessage());
513                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
514         } Catch(UnknownException) {
515                 LogError("Exception: " << _rethrown_exception.GetMessage());
516                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
517         } Catch(ConversionException) {
518                 LogError("Exception: " << _rethrown_exception.GetMessage());
519                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
520         } Catch (PlatformException) {
521                 LogError("Exception: " << _rethrown_exception.GetMessage());
522                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
523         }
524
525         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
526 }
527
528 JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
529         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
530         LogDebug("entered");
531
532         Try {
533                 return diffTZDate(context, thisObject, argumentCount,  arguments, exception, EQUALSTO);
534         } Catch(NullPointerException) {
535                 LogError("Exception: " << _rethrown_exception.GetMessage());
536                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
537         } Catch(UnknownException) {
538                 LogError("Exception: " << _rethrown_exception.GetMessage());
539                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
540         } Catch (InvalidArgumentException) {
541                 LogError("Exception: " << _rethrown_exception.GetMessage());
542                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
543         } Catch(ConversionException) {
544                 LogError("Exception: " << _rethrown_exception.GetMessage());
545                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
546         } Catch (PlatformException) {
547                 LogError("Exception: " << _rethrown_exception.GetMessage());
548                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
549         }
550         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
551 }
552
553 JSValueRef JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
554         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
555         LogDebug("earlierThan entered");
556
557         Try {
558                 return diffTZDate(context, thisObject, argumentCount,  arguments, exception, EARLIERTHAN);
559         } Catch(NullPointerException) {
560                 LogError("Exception: " << _rethrown_exception.GetMessage());
561                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
562         } Catch(UnknownException) {
563                 LogError("Exception: " << _rethrown_exception.GetMessage());
564                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
565         } Catch (InvalidArgumentException) {
566                 LogError("Exception: " << _rethrown_exception.GetMessage());
567                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
568         } Catch(ConversionException) {
569                 LogError("Exception: " << _rethrown_exception.GetMessage());
570                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
571         } Catch (PlatformException) {
572                 LogError("Exception: " << _rethrown_exception.GetMessage());
573                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
574         }
575         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
576
577 }
578
579 JSValueRef JSTZDate::laterThan(JSContextRef context, JSObjectRef function,
580         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
581
582         LogDebug("laterThan entered");
583
584         Try {
585                 return diffTZDate(context, thisObject, argumentCount,  arguments, exception, LATERTHAN);
586         } Catch(NullPointerException) {
587                 LogError("Exception: " << _rethrown_exception.GetMessage());
588                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
589         } Catch(UnknownException) {
590                 LogError("Exception: " << _rethrown_exception.GetMessage());
591                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
592         } Catch (InvalidArgumentException) {
593                 LogError("Exception: " << _rethrown_exception.GetMessage());
594                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
595         } Catch(ConversionException) {
596                 LogError("Exception: " << _rethrown_exception.GetMessage());
597                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
598         } Catch (PlatformException) {
599                 LogError("Exception: " << _rethrown_exception.GetMessage());
600                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
601         }
602         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
603
604 }
605
606 JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
607         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
608
609         LogDebug("addDuration entered");
610         Try {
611                 if (argumentCount != 1) {
612                         LogError("Wrong argument count");
613                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
614                 }
615
616                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
617                 if (!privateObject) {
618                         LogError("Private object is not set.");
619                         ThrowMsg(NullPointerException, "Private object not initialized");
620                 }
621
622                 TimeUtilConverter converter(context);
623
624                 DurationProperties duration = converter.getDurationPropertis(arguments[0]);
625
626                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
627                         privateObject->getContext(),
628                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
629                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
630
631                 ITZDatePtr TZDate(privateObject->getObject());
632                 TZDateProperties result = TZDate->addDuration(duration);
633                 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
634         } Catch(NullPointerException) {
635                 LogError("Exception: " << _rethrown_exception.GetMessage());
636                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
637         } Catch(UnknownException) {
638                 LogError("Exception: " << _rethrown_exception.GetMessage());
639                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
640         } Catch (InvalidArgumentException) {
641                 LogError("Exception: " << _rethrown_exception.GetMessage());
642                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
643         } Catch(ConversionException) {
644                 LogError("Exception: " << _rethrown_exception.GetMessage());
645                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
646         } Catch (PlatformException) {
647                 LogError("Exception: " << _rethrown_exception.GetMessage());
648                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
649         }
650         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
651 }
652
653 JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
654         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
655
656         LogDebug("toUTC entered");
657         Try {
658                 if (argumentCount != 0) {
659                         LogError("Wrong argument count");
660                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
661                 }
662
663                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
664                 if (!privateObject) {
665                         LogError("Private object is not set.");
666                         ThrowMsg(NullPointerException, "Private object not initialized");
667                 }
668
669                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
670                         privateObject->getContext(),
671                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
672                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
673
674                 ITZDatePtr TZDate(privateObject->getObject());
675                 TZDateProperties result = TZDate->toUTC();
676                 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
677         } Catch(NullPointerException) {
678                 LogError("Exception: " << _rethrown_exception.GetMessage());
679                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
680         } Catch(UnknownException) {
681                 LogError("Exception: " << _rethrown_exception.GetMessage());
682                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
683         } Catch (InvalidArgumentException) {
684                 LogError("Exception: " << _rethrown_exception.GetMessage());
685                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
686         } Catch (PlatformException) {
687                 LogError("Exception: " << _rethrown_exception.GetMessage());
688                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
689         }
690         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
691 }
692
693
694 JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
695         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
696
697         LogDebug("toLocalTimezone entered");
698         Try {
699                 if (argumentCount != 0) {
700                         LogError("Wrong argument count");
701                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
702                 }
703
704                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
705                 if (!privateObject) {
706                         LogError("Private object is not set.");
707                         ThrowMsg(NullPointerException, "Private object not initialized");
708                 }
709
710                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
711                         privateObject->getContext(),
712                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
713                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
714
715                 ITZDatePtr TZDate(privateObject->getObject());
716                 TZDateProperties result = TZDate->toLocalTimezone();
717                 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
718         } Catch(NullPointerException) {
719                 LogError("Exception: " << _rethrown_exception.GetMessage());
720                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
721         } Catch(UnknownException) {
722                 LogError("Exception: " << _rethrown_exception.GetMessage());
723                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
724         } Catch (InvalidArgumentException) {
725                 LogError("Exception: " << _rethrown_exception.GetMessage());
726                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
727         } Catch (PlatformException) {
728                 LogError("Exception: " << _rethrown_exception.GetMessage());
729                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
730         }
731         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
732 }
733
734 JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef function,
735         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
736         LogDebug("Entered");
737         Try {
738                 if (argumentCount != 0) {
739                         LogError("Wrong argument count");
740                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
741                 }
742
743                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
744                 if (!privateObject) {
745                         LogError("Private object is not set.");
746                         ThrowMsg(NullPointerException, "Private object not initialized");
747                 }
748
749                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
750                         privateObject->getContext(),
751                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
752                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
753
754                 TimeUtilConverter converter(context);
755
756                 ITZDatePtr TZDate(privateObject->getObject());
757                 std::string result = TZDate->toDateString(true);
758                 return converter.toJSValueRef(result);
759         } Catch(NullPointerException) {
760                 LogError("Exception: " << _rethrown_exception.GetMessage());
761                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
762         } Catch(UnknownException) {
763                 LogError("Exception: " << _rethrown_exception.GetMessage());
764                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
765         } Catch (InvalidArgumentException) {
766                 LogError("Exception: " << _rethrown_exception.GetMessage());
767                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
768         } Catch (PlatformException) {
769                 LogError("Exception: " << _rethrown_exception.GetMessage());
770                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
771         }
772
773         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
774 }
775
776 JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef function,
777         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
778         LogDebug("Entered");
779         Try {
780                 if (argumentCount != 0) {
781                         LogError("Wrong argument count");
782                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
783                 }
784
785                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
786                 if (!privateObject) {
787                         LogError("Private object is not set.");
788                         ThrowMsg(NullPointerException, "Private object not initialized");
789                 }
790
791                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
792                         privateObject->getContext(),
793                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
794                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
795
796                 TimeUtilConverter converter(context);
797
798                 ITZDatePtr TZDate(privateObject->getObject());
799                 std::string result = TZDate->toTimeString(true);
800                 return converter.toJSValueRef(result);
801         } Catch(NullPointerException) {
802                 LogError("Exception: " << _rethrown_exception.GetMessage());
803                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
804         } Catch(UnknownException) {
805                 LogError("Exception: " << _rethrown_exception.GetMessage());
806                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
807         } Catch (InvalidArgumentException) {
808                 LogError("Exception: " << _rethrown_exception.GetMessage());
809                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
810         } Catch (PlatformException) {
811                 LogError("Exception: " << _rethrown_exception.GetMessage());
812                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
813         }
814
815         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
816 }
817
818 JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
819         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
820         LogDebug("Entered");
821         Try {
822                 if (argumentCount != 0) {
823                         LogError("Wrong argument count");
824                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
825                 }
826
827                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
828                 if (!privateObject) {
829                         LogError("Private object is not set.");
830                         ThrowMsg(NullPointerException, "Private object not initialized");
831                 }
832
833                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
834                         privateObject->getContext(),
835                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
836                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
837
838                 TimeUtilConverter converter(context);
839
840                 ITZDatePtr TZDate(privateObject->getObject());
841                 std::string result = TZDate->toString(true);
842                 return converter.toJSValueRef(result);
843         } Catch(NullPointerException) {
844                 LogError("Exception: " << _rethrown_exception.GetMessage());
845                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
846         } Catch(UnknownException) {
847                 LogError("Exception: " << _rethrown_exception.GetMessage());
848                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
849         } Catch (InvalidArgumentException) {
850                 LogError("Exception: " << _rethrown_exception.GetMessage());
851                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
852         } Catch (PlatformException) {
853                 LogError("Exception: " << _rethrown_exception.GetMessage());
854                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
855         }
856
857         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
858 }
859
860 JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
861         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
862         LogDebug("Entered");
863         Try {
864                 if (argumentCount != 0) {
865                         LogError("Wrong argument count");
866                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
867                 }
868
869                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
870                 if (!privateObject) {
871                         LogError("Private object is not set.");
872                         ThrowMsg(NullPointerException, "Private object not initialized");
873                 }
874
875                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
876                         privateObject->getContext(),
877                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
878                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
879
880                 TimeUtilConverter converter(context);
881
882                 ITZDatePtr TZDate(privateObject->getObject());
883                 std::string result = TZDate->toDateString();
884                 return converter.toJSValueRef(result);
885         } Catch(NullPointerException) {
886                 LogError("Exception: " << _rethrown_exception.GetMessage());
887                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
888         } Catch(UnknownException) {
889                 LogError("Exception: " << _rethrown_exception.GetMessage());
890                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
891         } Catch (InvalidArgumentException) {
892                 LogError("Exception: " << _rethrown_exception.GetMessage());
893                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
894         } Catch (PlatformException) {
895                 LogError("Exception: " << _rethrown_exception.GetMessage());
896                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
897         }
898
899         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
900 }
901
902 JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
903         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
904         LogDebug("Entered");
905         Try {
906                 if (argumentCount != 0) {
907                         LogError("Wrong argument count");
908                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
909                 }
910
911                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
912                 if (!privateObject) {
913                         LogError("Private object is not set.");
914                         ThrowMsg(NullPointerException, "Private object not initialized");
915                 }
916
917                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
918                         privateObject->getContext(),
919                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
920                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
921
922                 TimeUtilConverter converter(context);
923
924                 ITZDatePtr TZDate(privateObject->getObject());
925                 std::string result = TZDate->toTimeString();
926                 return converter.toJSValueRef(result);
927         } Catch(NullPointerException) {
928                 LogError("Exception: " << _rethrown_exception.GetMessage());
929                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
930         } Catch(UnknownException) {
931                 LogError("Exception: " << _rethrown_exception.GetMessage());
932                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
933         } Catch (InvalidArgumentException) {
934                 LogError("Exception: " << _rethrown_exception.GetMessage());
935                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
936         } Catch (PlatformException) {
937                 LogError("Exception: " << _rethrown_exception.GetMessage());
938                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
939         }
940
941         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
942 }
943
944
945 JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
946         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
947         LogDebug("Entered");
948         Try {
949                 if (argumentCount != 0) {
950                         LogError("Wrong argument count");
951                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
952                 }
953
954                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
955                 if (!privateObject) {
956                         LogError("Private object is not set.");
957                         ThrowMsg(NullPointerException, "Private object not initialized");
958                 }
959
960                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
961                         privateObject->getContext(),
962                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
963                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
964
965                 TimeUtilConverter converter(context);
966
967                 ITZDatePtr TZDate(privateObject->getObject());
968                 std::string result = TZDate->toString();
969                 return converter.toJSValueRef(result);
970         } Catch(NullPointerException) {
971                 LogError("Exception: " << _rethrown_exception.GetMessage());
972                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
973         } Catch(UnknownException) {
974                 LogError("Exception: " << _rethrown_exception.GetMessage());
975                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
976         } Catch (InvalidArgumentException) {
977                 LogError("Exception: " << _rethrown_exception.GetMessage());
978                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
979         } Catch (PlatformException) {
980                 LogError("Exception: " << _rethrown_exception.GetMessage());
981                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
982         }
983
984         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
985 }
986
987 JSValueRef JSTZDate::getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
988         JSValueRef * exception) {
989         LogDebug("<<<");
990
991         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
992         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
993 } //getDate()
994
995 JSValueRef JSTZDate::getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
996         JSValueRef * exception) {
997         LogDebug("<<<");
998
999         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DAY_OF_WEEK;
1000         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1001 } //getDay()
1002
1003 JSValueRef JSTZDate::getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1004         JSValueRef * exception) {
1005         LogDebug("<<<");
1006
1007         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
1008         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1009 } //getFullYear()
1010
1011 JSValueRef JSTZDate::getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1012         JSValueRef * exception) {
1013         LogDebug("<<<");
1014
1015         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
1016         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1017 } //getHours()
1018
1019 JSValueRef JSTZDate::getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1020         JSValueRef * exception) {
1021         LogDebug("<<<");
1022
1023         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
1024         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1025 } //getMilliseconds()
1026
1027 JSValueRef JSTZDate::getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1028         JSValueRef * exception) {
1029         LogDebug("<<<");
1030
1031         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
1032         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1033 } //getMinutes()
1034
1035 JSValueRef JSTZDate::getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1036         JSValueRef * exception) {
1037         LogDebug("<<<");
1038         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
1039         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1040 } //getMonth()
1041
1042 JSValueRef JSTZDate::getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1043         JSValueRef * exception) {
1044         LogDebug("<<<");
1045
1046         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
1047         return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1048 } //getSeconds()
1049
1050 JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
1051         ITZDate::TZDateFields dateFields) {
1052         try {
1053                 if (argumentCount != 0) {
1054                         LogError("Wrong argument count");
1055                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1056                 }
1057
1058                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1059
1060                 if (privateObject == NULL) {
1061                         LogError(">>> NULL Exception");
1062                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1063                 }
1064
1065                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1066                         privateObject->getContext(),
1067                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1068                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1069
1070                 ITZDatePtr tzDate(privateObject->getObject());
1071                 long retVal = tzDate->get(dateFields);
1072
1073                 TimeUtilConverter converter(context);
1074                 LogDebug(">>> retVal:" << retVal);
1075                 return converter.toJSValueRef(static_cast<int> (retVal));
1076         } Catch(NullPointerException) {
1077                 LogError("Exception: " << _rethrown_exception.GetMessage());
1078                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1079         } Catch(UnknownException) {
1080                 LogError("Exception: " << _rethrown_exception.GetMessage());
1081                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1082         } Catch (InvalidArgumentException) {
1083                 LogError("Exception: " << _rethrown_exception.GetMessage());
1084                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1085         } Catch (PlatformException) {
1086                 LogError("Exception: " << _rethrown_exception.GetMessage());
1087                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1088         }
1089
1090         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1091 }
1092
1093 JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1094         JSValueRef * exception) {
1095         LogDebug("<<<");
1096
1097         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
1098
1099         try{
1100                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1101         } Catch(NullPointerException) {
1102                 LogError("Exception: " << _rethrown_exception.GetMessage());
1103                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1104         } Catch(UnknownException) {
1105                 LogError("Exception: " << _rethrown_exception.GetMessage());
1106                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1107         } Catch (InvalidArgumentException) {
1108                 LogError("Exception: " << _rethrown_exception.GetMessage());
1109                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1110         } Catch(ConversionException) {
1111                 LogError("Exception: " << _rethrown_exception.GetMessage());
1112                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1113         } Catch (PlatformException) {
1114                 LogError("Exception: " << _rethrown_exception.GetMessage());
1115                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1116         }
1117
1118         return JSValueMakeNull(context);
1119 } //setDate()
1120
1121 JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1122         JSValueRef * exception) {
1123         LogDebug("<<<");
1124
1125         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
1126
1127         try{
1128                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1129         } Catch(NullPointerException) {
1130                 LogError("Exception: " << _rethrown_exception.GetMessage());
1131                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1132         } Catch(UnknownException) {
1133                 LogError("Exception: " << _rethrown_exception.GetMessage());
1134                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1135         } Catch (InvalidArgumentException) {
1136                 LogError("Exception: " << _rethrown_exception.GetMessage());
1137                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1138         } Catch(ConversionException) {
1139                 LogError("Exception: " << _rethrown_exception.GetMessage());
1140                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1141         } Catch (PlatformException) {
1142                 LogError("Exception: " << _rethrown_exception.GetMessage());
1143                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1144         }
1145
1146         return JSValueMakeNull(context);
1147 } //setFullYear()
1148
1149 JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1150         JSValueRef * exception) {
1151         LogDebug("<<<");
1152
1153         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
1154
1155         Try {
1156                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1157         } Catch(NullPointerException) {
1158                 LogError("Exception: " << _rethrown_exception.GetMessage());
1159                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1160         } Catch(UnknownException) {
1161                 LogError("Exception: " << _rethrown_exception.GetMessage());
1162                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1163         } Catch (InvalidArgumentException) {
1164                 LogError("Exception: " << _rethrown_exception.GetMessage());
1165                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1166         } Catch(ConversionException) {
1167                 LogError("Exception: " << _rethrown_exception.GetMessage());
1168                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1169         } Catch (PlatformException) {
1170                 LogError("Exception: " << _rethrown_exception.GetMessage());
1171                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1172         }
1173
1174         return JSValueMakeNull(context);
1175 } //setHours()
1176
1177 JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1178         JSValueRef * exception) {
1179         LogDebug("<<<");
1180
1181         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
1182         
1183         Try{
1184                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1185         } Catch(NullPointerException) {
1186                 LogError("Exception: " << _rethrown_exception.GetMessage());
1187                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1188         } Catch(UnknownException) {
1189                 LogError("Exception: " << _rethrown_exception.GetMessage());
1190                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1191         } Catch (InvalidArgumentException) {
1192                 LogError("Exception: " << _rethrown_exception.GetMessage());
1193                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1194         } Catch(ConversionException) {
1195                 LogError("Exception: " << _rethrown_exception.GetMessage());
1196                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1197         } Catch (PlatformException) {
1198                 LogError("Exception: " << _rethrown_exception.GetMessage());
1199                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1200         }
1201
1202         return JSValueMakeNull(context);
1203 } //setMilliseconds()
1204
1205 JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1206         JSValueRef * exception) {
1207         LogDebug("<<<");
1208
1209         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
1210
1211         Try {
1212                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1213         } Catch(NullPointerException) {
1214                 LogError("Exception: " << _rethrown_exception.GetMessage());
1215                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1216         } Catch(UnknownException) {
1217                 LogError("Exception: " << _rethrown_exception.GetMessage());
1218                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1219         } Catch (InvalidArgumentException) {
1220                 LogError("Exception: " << _rethrown_exception.GetMessage());
1221                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1222         } Catch(ConversionException) {
1223                 LogError("Exception: " << _rethrown_exception.GetMessage());
1224                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1225         } Catch (PlatformException) {
1226                 LogError("Exception: " << _rethrown_exception.GetMessage());
1227                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1228         }
1229
1230         return JSValueMakeNull(context);
1231 } //setMinutes()
1232
1233 JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1234         JSValueRef * exception) {
1235         LogDebug("<<<");
1236
1237         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
1238
1239         Try {
1240                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1241         } Catch(NullPointerException) {
1242                 LogError("Exception: " << _rethrown_exception.GetMessage());
1243                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1244         } Catch(UnknownException) {
1245                 LogError("Exception: " << _rethrown_exception.GetMessage());
1246                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1247         } Catch (InvalidArgumentException) {
1248                 LogError("Exception: " << _rethrown_exception.GetMessage());
1249                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1250         } Catch(ConversionException) {
1251                 LogError("Exception: " << _rethrown_exception.GetMessage());
1252                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1253         } Catch (PlatformException) {
1254                 LogError("Exception: " << _rethrown_exception.GetMessage());
1255                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1256         }
1257
1258         return JSValueMakeNull(context);
1259 } //setMonth()
1260
1261 JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1262         JSValueRef * exception) {
1263         LogDebug("<<<");
1264
1265         ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
1266
1267         Try {
1268                 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1269         } Catch(NullPointerException) {
1270                 LogError("Exception: " << _rethrown_exception.GetMessage());
1271                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1272         } Catch(UnknownException) {
1273                 LogError("Exception: " << _rethrown_exception.GetMessage());
1274                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1275         } Catch (InvalidArgumentException) {
1276                 LogError("Exception: " << _rethrown_exception.GetMessage());
1277                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1278         } Catch(ConversionException) {
1279                 LogError("Exception: " << _rethrown_exception.GetMessage());
1280                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1281         } Catch (PlatformException) {
1282                 LogError("Exception: " << _rethrown_exception.GetMessage());
1283                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1284         }
1285
1286         return JSValueMakeNull(context);
1287 } //setSeconds()
1288
1289
1290 JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1291         JSValueRef * exception, ITZDate::TZDateFields dateFields) {
1292
1293         if (argumentCount != 1) {
1294                 LogError("Wrong parameters");
1295                 ThrowMsg(InvalidArgumentException, "argumentIndex is bigger than argumentCount");
1296         }
1297
1298         TimeUtilConverter converter(context);
1299
1300         if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
1301                 || (!JSValueIsNumber(context, arguments[0])))
1302                 ThrowMsg(ConversionException, "Invalid Argument");
1303
1304         int data = converter.toInt(arguments[0]);
1305
1306         if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
1307                 ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1308
1309         TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1310
1311         if (privateObject == NULL) {
1312                 LogError(">>> NULL Exception");
1313                 ThrowMsg(UnknownException, "privateObject is NULL");
1314         }
1315
1316         AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1317                 privateObject->getContext(),
1318                 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1319         TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1320
1321         ITZDatePtr tzDate(privateObject->getObject());
1322         tzDate->set(dateFields, static_cast<long> (data));
1323
1324         return JSValueMakeNull(context);
1325 }       //setTZDateValue
1326
1327 JSValueRef JSTZDate::getUTCDate(JSContextRef context, JSObjectRef function,
1328         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1329         LogDebug("Entered");
1330         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_DATE, exception);
1331 }
1332
1333 JSValueRef JSTZDate::getUTCDay(JSContextRef context, JSObjectRef function,
1334         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1335         LogDebug("Entered");
1336         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_DAY_OF_WEEK, exception);
1337 }
1338
1339 JSValueRef JSTZDate::getUTCFullYear(JSContextRef context, JSObjectRef function,
1340         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1341         LogDebug("Entered");
1342         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_YEAR, exception);
1343 }
1344
1345 JSValueRef JSTZDate::getUTCHours(JSContextRef context, JSObjectRef function,
1346         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1347         LogDebug("Entered");
1348         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_HOUR_OF_DAY, exception);
1349 }
1350
1351 JSValueRef JSTZDate::getUTCMilliseconds(JSContextRef context, JSObjectRef function,
1352         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1353         LogDebug("Entered");
1354         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MILLISECOND, exception);
1355 }
1356
1357 JSValueRef JSTZDate::getUTCMinutes(JSContextRef context, JSObjectRef function,
1358         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1359         LogDebug("Entered");
1360         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MINUTE, exception);
1361 }
1362
1363 JSValueRef JSTZDate::getUTCMonth(JSContextRef context, JSObjectRef function,
1364         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1365         LogDebug("Entered");
1366         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MONTH, exception);
1367 }
1368
1369 JSValueRef JSTZDate::getUTCSeconds(JSContextRef context, JSObjectRef function,
1370         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1371         LogDebug("Entered");
1372         return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_SECOND, exception);
1373 }
1374
1375 JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, ITZDate::TZDateFields DateFields, JSValueRef * exception) {
1376         LogDebug("Entered");
1377         Try {
1378                 if (argumentCount != 0) {
1379                         LogError("Wrong argument count");
1380                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1381                 }
1382
1383                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1384                 if (!privateObject) {
1385                         LogError("Private object is not set.");
1386                         ThrowMsg(NullPointerException, "Private object not initialized");
1387                 }
1388
1389                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1390                         privateObject->getContext(),
1391                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1392                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1393
1394                 TimeUtilConverter converter(context);
1395
1396                 ITZDatePtr TZDate(privateObject->getObject());
1397                 long result = TZDate->getUTC(DateFields);
1398
1399                 return converter.toJSValueRefLong(result);
1400         } Catch(NullPointerException) {
1401                 LogError("Exception: " << _rethrown_exception.GetMessage());
1402                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1403         } Catch(UnknownException) {
1404                 LogError("Exception: " << _rethrown_exception.GetMessage());
1405                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1406         } Catch (InvalidArgumentException) {
1407                 LogError("Exception: " << _rethrown_exception.GetMessage());
1408                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1409         } Catch (PlatformException) {
1410                 LogError("Exception: " << _rethrown_exception.GetMessage());
1411                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1412         }
1413
1414         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1415 }
1416
1417 JSValueRef JSTZDate::setUTCDate(JSContextRef context, JSObjectRef function,
1418         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1419         LogDebug("Entered");
1420
1421         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_DATE, exception);
1422 }
1423
1424 JSValueRef JSTZDate::setUTCFullYear(JSContextRef context, JSObjectRef function,
1425         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1426         LogDebug("Entered");
1427
1428         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_YEAR, exception);
1429 }
1430
1431 JSValueRef JSTZDate::setUTCHours(JSContextRef context, JSObjectRef function,
1432         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1433         LogDebug("Entered");
1434
1435         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_HOUR_OF_DAY, exception);
1436 }
1437
1438 JSValueRef JSTZDate::setUTCMilliseconds(JSContextRef context, JSObjectRef function,
1439         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1440         LogDebug("Entered");
1441
1442         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MILLISECOND, exception);
1443 }
1444
1445 JSValueRef JSTZDate::setUTCMinutes(JSContextRef context, JSObjectRef function,
1446         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1447         LogDebug("Entered");
1448
1449         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MINUTE, exception);
1450 }
1451
1452 JSValueRef JSTZDate::setUTCMonth(JSContextRef context, JSObjectRef function,
1453         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1454         LogDebug("Entered");
1455
1456         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MONTH, exception);
1457 }
1458
1459 JSValueRef JSTZDate::setUTCSeconds(JSContextRef context, JSObjectRef function,
1460         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1461         LogDebug("Entered");
1462
1463         return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_SECOND, exception);
1464 }
1465
1466 JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject,
1467         size_t argumentCount, const JSValueRef arguments[], ITZDate::TZDateFields dateFields, JSValueRef * exception) {
1468         LogDebug("Entered");
1469         Try {
1470                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1471                 if (!privateObject) {
1472                         LogError("Private object is not set.");
1473                         ThrowMsg(NullPointerException, "Private object not initialized");
1474                 }
1475
1476                 if (argumentCount != 1) {
1477                         LogError("Wrong TZDate parameters count");
1478                         ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
1479                 }
1480                         
1481                 if (!JSValueIsNumber(context, arguments[0]))
1482                 {
1483                         LogError("Wrong TZDate parameters");
1484                         ThrowMsg(ConversionException, "Wrong TZDate parameters");
1485                 }
1486
1487                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1488                         privateObject->getContext(),
1489                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1490                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1491
1492                 TimeUtilConverter converter(context);
1493                 
1494                 long data = converter.FromJSValueReftolong(arguments[0]);
1495
1496                 if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
1497                         ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1498         
1499                 ITZDatePtr TZDate(privateObject->getObject());
1500                 TZDate->setUTC(dateFields, data);
1501
1502                 return JSValueMakeNull(context);
1503         } Catch(NullPointerException) {
1504                 LogError("Exception: " << _rethrown_exception.GetMessage());
1505                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1506         } Catch(UnknownException) {
1507                 LogError("Exception: " << _rethrown_exception.GetMessage());
1508                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1509         } Catch (InvalidArgumentException) {
1510                 LogError("Exception: " << _rethrown_exception.GetMessage());
1511                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1512         } Catch(ConversionException) {
1513                 LogError("Exception: " << _rethrown_exception.GetMessage());
1514                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1515         } Catch (PlatformException) {
1516                 LogError("Exception: " << _rethrown_exception.GetMessage());
1517                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1518         }
1519
1520         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1521 }
1522
1523 JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1524         LogDebug("entered");
1525         Try {
1526                 if (argumentCount != 0) {
1527                         LogError("Wrong argument count");
1528                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1529                 }
1530
1531                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1532                 if (!privateObject) {
1533                         LogError("Private object is not set.");
1534                         ThrowMsg(NullPointerException, "Private object not initialized");
1535                 }
1536
1537                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1538                         privateObject->getContext(),
1539                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1540                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1541
1542                 TimeUtilConverter converter(context);
1543
1544                 ITZDatePtr tzDate(privateObject->getObject());
1545
1546                 std::string result;
1547
1548                 return converter.toJSValueRef(tzDate->getTimezoneAbbreviation());
1549         } Catch(NullPointerException) {
1550                 LogError("Exception: " << _rethrown_exception.GetMessage());
1551                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1552         } Catch(UnknownException) {
1553                 LogError("Exception: " << _rethrown_exception.GetMessage());
1554                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1555         } Catch (InvalidArgumentException) {
1556                 LogError("Exception: " << _rethrown_exception.GetMessage());
1557                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1558         } Catch (PlatformException) {
1559                 LogError("Exception: " << _rethrown_exception.GetMessage());
1560                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1561         }
1562         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1563 }
1564
1565 JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1566         LogDebug("entered");
1567
1568         Try {
1569                 if (argumentCount != 0) {
1570                         LogError("Wrong argument count");
1571                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1572                 }
1573
1574                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1575                 if (!privateObject) {
1576                         LogError("Private object is not set.");
1577                         ThrowMsg(NullPointerException, "Private object not initialized");
1578                 }
1579
1580                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1581                         privateObject->getContext(),
1582                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1583                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1584
1585                 TimeUtilConverter converter(context);
1586
1587                 ITZDatePtr tzDate(privateObject->getObject());
1588
1589                 return converter.toJSValueRefLong(tzDate->secondsFromUTC());
1590         } Catch(NullPointerException) {
1591                 LogError("Exception: " << _rethrown_exception.GetMessage());
1592                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1593         } Catch(UnknownException) {
1594                 LogError("Exception: " << _rethrown_exception.GetMessage());
1595                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1596         } Catch (InvalidArgumentException) {
1597                 LogError("Exception: " << _rethrown_exception.GetMessage());
1598                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1599         } Catch (PlatformException) {
1600                 LogError("Exception: " << _rethrown_exception.GetMessage());
1601                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1602         }
1603         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1604 }
1605 JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1606         LogDebug("entered");
1607         Try {
1608                 if (argumentCount != 0) {
1609                         LogError("Wrong argument count");
1610                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1611                 }
1612
1613                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1614                 if (!privateObject) {
1615                         LogError("Private object is not set.");
1616                         ThrowMsg(NullPointerException, "Private object not initialized");
1617                 }
1618
1619                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1620                         privateObject->getContext(),
1621                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1622                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1623
1624                 TimeUtilConverter converter(context);
1625
1626                 ITZDatePtr tzDate(privateObject->getObject());
1627
1628                 return converter.toJSValueRef(tzDate->isDST());
1629         } Catch(NullPointerException) {
1630                 LogError("Exception: " << _rethrown_exception.GetMessage());
1631                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1632         } Catch(UnknownException) {
1633                 LogError("Exception: " << _rethrown_exception.GetMessage());
1634                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1635         } Catch (InvalidArgumentException) {
1636                 LogError("Exception: " << _rethrown_exception.GetMessage());
1637                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1638         } Catch (PlatformException) {
1639                 LogError("Exception: " << _rethrown_exception.GetMessage());
1640                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1641         }
1642         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1643 }
1644
1645 JSValueRef JSTZDate::getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1646         LogDebug("entered");
1647
1648         Try {
1649                 if (argumentCount != 0) {
1650                         LogError("Wrong argument count");
1651                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1652                 }
1653
1654                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1655                 if (!privateObject) {
1656                         LogError("Private object is not set.");
1657                         ThrowMsg(NullPointerException, "Private object not initialized");
1658                 }
1659
1660                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1661                         privateObject->getContext(),
1662                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1663                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1664                 
1665                 TimeUtilConverter converter(context);
1666
1667                 ITZDatePtr tzDate(privateObject->getObject());
1668
1669                 return createJSObject(privateObject->getContext(), tzDate->getDSTTransition(ITZDate::PREV_TRANSITION));
1670         } Catch(NullPointerException) {
1671                 LogError("Exception: " << _rethrown_exception.GetMessage());
1672                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1673         } Catch(UnknownException) {
1674                 LogError("Exception: " << _rethrown_exception.GetMessage());
1675                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1676         } Catch (InvalidArgumentException) {
1677                 LogError("Exception: " << _rethrown_exception.GetMessage());
1678                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1679         } Catch (PlatformException) {
1680                 LogError("Exception: " << _rethrown_exception.GetMessage());
1681                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1682         }
1683         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1684 }
1685
1686 JSValueRef JSTZDate::getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1687         LogDebug("entered");
1688
1689         Try {
1690                 if (argumentCount != 0) {
1691                         LogError("Wrong argument count");
1692                         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1693                 }
1694
1695                 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1696                 if (!privateObject) {
1697                         LogError("Private object is not set.");
1698                         ThrowMsg(NullPointerException, "Private object not initialized");
1699                 }
1700
1701                 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1702                         privateObject->getContext(),
1703                         TIMEUTIL_FUNCTION_API_READ_FUNCS);
1704                 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1705                 
1706                 TimeUtilConverter converter(context);
1707
1708                 ITZDatePtr tzDate(privateObject->getObject());
1709
1710                 return createJSObject(privateObject->getContext(), tzDate->getDSTTransition(ITZDate::NEXT_TRANSITION));
1711         } Catch(NullPointerException) {
1712                 LogError("Exception: " << _rethrown_exception.GetMessage());
1713                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1714         } Catch(UnknownException) {
1715                 LogError("Exception: " << _rethrown_exception.GetMessage());
1716                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1717         } Catch (InvalidArgumentException) {
1718                 LogError("Exception: " << _rethrown_exception.GetMessage());
1719                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1720         } Catch (PlatformException) {
1721                 LogError("Exception: " << _rethrown_exception.GetMessage());
1722                 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1723         }
1724         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1725 }
1726
1727 }               //Tizen1_0
1728 }               //TizenApis
1729 #undef min