2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
21 #include <CommonsJavaScript/PrivateObject.h>
22 #include <CommonsJavaScript/JSUtils.h>
23 #include <Commons/Exception.h>
24 #include <JSTizenExceptionFactory.h>
25 #include <JSTizenException.h>
26 #include <ArgumentValidator.h>
27 #include <JSWebAPIException.h>
29 #include "DurationProperties.h"
31 #include "TimeUtilConverter.h"
34 using namespace DeviceAPI::Common;
35 using namespace WrtDeviceApis::Commons;
36 using namespace WrtDeviceApis::CommonsJavaScript;
38 #define min(a,b) (((a) < (b)) ? (a) : (b))
40 #define TZDATE_ATTRIBUTENAME "TZDate"
45 JSClassDefinition JSTZDate::m_classInfo =
48 kJSClassAttributeNone,
58 NULL, //DeleteProperty,
59 NULL, //GetPropertyNames,
60 NULL, //CallAsFunction,
61 NULL, //CallAsConstructor,
66 JSStaticFunction JSTZDate::m_function[] = {
67 {"getDate", JSTZDate::getDate, kJSPropertyAttributeNone},
68 {"getDay", JSTZDate::getDay, kJSPropertyAttributeNone},
69 {"getFullYear", JSTZDate::getFullYear, kJSPropertyAttributeNone},
70 {"getHours", JSTZDate::getHours, kJSPropertyAttributeNone},
71 {"getMilliseconds", JSTZDate::getMilliseconds, kJSPropertyAttributeNone},
72 {"getMinutes", JSTZDate::getMinutes, kJSPropertyAttributeNone},
73 {"getMonth", JSTZDate::getMonth, kJSPropertyAttributeNone},
74 {"getSeconds", JSTZDate::getSeconds, kJSPropertyAttributeNone},
76 {"setDate", JSTZDate::setDate, kJSPropertyAttributeNone},
77 {"setFullYear", JSTZDate::setFullYear, kJSPropertyAttributeNone},
78 {"setHours", JSTZDate::setHours, kJSPropertyAttributeNone},
79 {"setMilliseconds", JSTZDate::setMilliseconds, kJSPropertyAttributeNone},
80 {"setMinutes", JSTZDate::setMinutes, kJSPropertyAttributeNone},
81 {"setMonth", JSTZDate::setMonth, kJSPropertyAttributeNone},
82 {"setSeconds", JSTZDate::setSeconds, kJSPropertyAttributeNone},
84 {"getUTCDate", JSTZDate::getUTCDate, kJSPropertyAttributeNone},
85 {"getUTCDay", JSTZDate::getUTCDay, kJSPropertyAttributeNone},
86 {"getUTCFullYear", JSTZDate::getUTCFullYear, kJSPropertyAttributeNone},
87 {"getUTCHours", JSTZDate::getUTCHours, kJSPropertyAttributeNone},
88 {"getUTCMilliseconds", JSTZDate::getUTCMilliseconds, kJSPropertyAttributeNone},
89 {"getUTCMinutes", JSTZDate::getUTCMinutes, kJSPropertyAttributeNone},
90 {"getUTCMonth", JSTZDate::getUTCMonth, kJSPropertyAttributeNone},
91 {"getUTCSeconds", JSTZDate::getUTCSeconds, kJSPropertyAttributeNone},
93 {"setUTCDate", JSTZDate::setUTCDate, kJSPropertyAttributeNone},
94 {"setUTCFullYear", JSTZDate::setUTCFullYear, kJSPropertyAttributeNone},
95 {"setUTCHours", JSTZDate::setUTCHours, kJSPropertyAttributeNone},
96 {"setUTCMilliseconds", JSTZDate::setUTCMilliseconds, kJSPropertyAttributeNone},
97 {"setUTCMinutes", JSTZDate::setUTCMinutes, kJSPropertyAttributeNone},
98 {"setUTCMonth", JSTZDate::setUTCMonth, kJSPropertyAttributeNone},
99 {"setUTCSeconds", JSTZDate::setUTCSeconds, kJSPropertyAttributeNone},
101 {"getTimezone", JSTZDate::getTimezone, kJSPropertyAttributeNone},
102 {"toTimezone", JSTZDate::toTimezone, kJSPropertyAttributeNone},
103 {"toLocalTimezone", JSTZDate::toLocalTimezone, kJSPropertyAttributeNone},
104 {"toUTC", JSTZDate::toUTC, kJSPropertyAttributeNone},
106 {"difference", JSTZDate::difference, kJSPropertyAttributeNone},
107 {"equalsTo", JSTZDate::equalsTo, kJSPropertyAttributeNone},
108 {"earlierThan", JSTZDate::earlierThan, kJSPropertyAttributeNone},
109 {"laterThan", JSTZDate::laterThan, kJSPropertyAttributeNone},
110 {"addDuration", JSTZDate::addDuration, kJSPropertyAttributeNone},
112 {"toLocaleDateString", JSTZDate::toLocaleDateString, kJSPropertyAttributeNone},
113 {"toLocaleTimeString", JSTZDate::toLocaleTimeString, kJSPropertyAttributeNone},
114 {"toLocaleString", JSTZDate::toLocaleString, kJSPropertyAttributeNone},
115 {"toDateString", JSTZDate::toDateString, kJSPropertyAttributeNone},
116 {"toTimeString", JSTZDate::toTimeString, kJSPropertyAttributeNone},
117 {"toString", JSTZDate::toString, kJSPropertyAttributeNone},
119 {"getTimezoneAbbreviation", JSTZDate::getTimezoneAbbreviation, kJSPropertyAttributeNone},
120 {"secondsFromUTC", JSTZDate::secondsFromUTC, kJSPropertyAttributeNone},
121 {"isDST", JSTZDate::isDST, kJSPropertyAttributeNone},
122 {"getPreviousDSTTransition", JSTZDate::getPreviousDSTTransition, kJSPropertyAttributeNone},
123 {"getNextDSTTransition", JSTZDate::getNextDSTTransition, kJSPropertyAttributeNone},
127 JSClassRef JSTZDate::m_jsClassRef = JSClassCreate(JSTZDate::getClassInfo());
129 JSObjectRef JSTZDate::createJSObject(JSContextRef context) {
131 TZDatePtr tzDate(new TZDate());
132 TZDatePrivObject *priv = new TZDatePrivObject(context, tzDate);
134 ThrowMsg(NullPointerException, "Can not new an object");
137 return JSObjectMake(context, getClassRef(), priv);
140 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const std::string &timezone) {
143 return createJSObject(context);
145 TZDatePtr tzDate(new TZDate(timezone));
146 TZDatePrivObject *priv = new TZDatePrivObject(context, tzDate);
148 ThrowMsg(NullPointerException, "Can not new an object");
151 return JSObjectMake(context, getClassRef(), priv);
154 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const double milliseconds, const std::string &timezone) {
158 tzDate = TZDatePtr(new TZDate());
160 tzDate = TZDatePtr(new TZDate(timezone));
162 if (!tzDate->setTime(milliseconds))
163 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "Can not set UTC Time");
165 TZDatePrivObject *priv = new TZDatePrivObject(context, tzDate);
167 ThrowMsg(NullPointerException, "Can not new an object");
170 return JSObjectMake(context, getClassRef(), priv);
173 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const TZDateProperties &properties) {
175 TZDatePtr tzDate(new TZDate(properties));
177 TZDatePrivObject *priv = new TZDatePrivObject(context, tzDate);
179 ThrowMsg(NullPointerException, "Can not new an object");
182 return JSObjectMake(context, getClassRef(), priv);
185 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) {
188 TZDateProperties props;
193 props.minutes = minutes;
194 props.seconds = seconds;
195 props.milliseconds = milliseconds;
196 props.timezone = timezone;
198 return createJSObject(context, props);
202 void JSTZDate::initialize(JSContextRef context, JSObjectRef object)
204 LoggerD("entered Nothing to do.");
207 void JSTZDate::finalize(JSObjectRef object)
209 LoggerD( "entered" );
210 TZDatePrivObject *priv =
211 static_cast<TZDatePrivObject*>( JSObjectGetPrivate( object ) ) ;
215 JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
218 TZDateProperties prop;
219 TimeUtilConverter converter(ctx);
222 JSObjectRef tzDate = NULL;
224 if (argumentCount == 0) {
225 tzDate = createJSObject(ctx);
226 } else if (argumentCount <= 2) {
227 std::string timezone = "";
228 if ((argumentCount == 2) && !JSValueIsNull(ctx, arguments[1]) && !JSValueIsUndefined(ctx, arguments[1])) {
229 timezone = converter.toString(arguments[1]);
232 if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0])) {
233 tzDate = createJSObject(ctx, timezone);
235 struct tm date = converter.toDateTm(arguments[0]);
236 LoggerD("date = " << date.tm_year << "." << date.tm_mon << "." << date.tm_mday);
237 LoggerD(date.tm_hour << ":" << date.tm_min << ":" << date.tm_sec);
238 LoggerD("isdst?" << date.tm_isdst);
240 prop.timezone = timezone;
241 prop.year = date.tm_year + 1900;
242 prop.month = date.tm_mon;
243 prop.day = date.tm_mday;
244 prop.hours = date.tm_hour;
245 prop.minutes = date.tm_min;
246 prop.seconds = date.tm_sec;
248 JSStringRef getMillisecondsName = JSStringCreateWithUTF8CString("getMilliseconds");
249 JSValueRef getMiliSecFuction = JSObjectGetProperty(ctx, converter.toJSObjectRef(arguments[0]), getMillisecondsName, exception);
250 JSStringRelease(getMillisecondsName);
251 if (getMiliSecFuction) {
252 JSObjectRef function = JSValueToObject(ctx, getMiliSecFuction, exception);
253 JSValueRef result = JSObjectCallAsFunction(ctx, function, converter.toJSObjectRef(arguments[0]), 0, NULL, exception);
254 prop.milliseconds = converter.toLong(result);
255 LoggerD("getMilliseconds = " << prop.milliseconds);
257 tzDate = createJSObject(ctx, prop);
260 prop.year = converter.toLong(arguments[0]);
261 if ((prop.year >= 0) && (prop.year <= 99))
263 prop.month = converter.toLong(arguments[1]);
264 prop.day = converter.toLong(arguments[2]);
265 if (argumentCount > 3) {
266 if (!JSValueIsUndefined(ctx, arguments[3]) && !JSValueIsNull(ctx, arguments[3]))
267 prop.hours = converter.toLong(arguments[3]);
268 if (argumentCount > 4) {
269 if (!JSValueIsUndefined(ctx, arguments[4]) && !JSValueIsNull(ctx, arguments[4]))
270 prop.minutes = converter.toLong(arguments[4]);
271 if (argumentCount > 5) {
272 if (!JSValueIsUndefined(ctx, arguments[5]) && !JSValueIsNull(ctx, arguments[5]))
273 prop.seconds = converter.toLong(arguments[5]);
274 if (argumentCount > 6) {
275 if (!JSValueIsUndefined(ctx, arguments[6]) && !JSValueIsNull(ctx, arguments[6]))
276 prop.milliseconds= converter.toLong(arguments[6]);
277 if (argumentCount > 7) {
278 if (!JSValueIsUndefined(ctx, arguments[7]) && !JSValueIsNull(ctx, arguments[7]))
279 prop.timezone = converter.toString(arguments[7]);
285 tzDate = createJSObject(ctx, prop);
289 JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
290 JSObjectSetProperty(ctx, tzDate, ctorName, constructor,
291 kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
292 JSStringRelease(ctorName);
295 } Catch(ConversionException) {
296 LoggerE("Exception: " << _rethrown_exception.GetMessage());
297 JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
300 } Catch (InvalidArgumentException) {
301 LoggerE("Exception: " << _rethrown_exception.GetMessage());
302 JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
305 } Catch (PlatformException) {
306 LoggerE("Exception: " << _rethrown_exception.GetMessage());
307 } Catch (WrtDeviceApis::Commons::Exception) {
308 LoggerE("Exception: " << _rethrown_exception.GetMessage());
310 JSObjectRef error = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
314 const JSClassRef JSTZDate::getClassRef()
317 m_jsClassRef = JSClassCreate(&m_classInfo);
322 const JSClassDefinition* JSTZDate::getClassInfo()
327 JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
328 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
332 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
333 if (!privateObject) {
334 LoggerE("Private object is not set.");
335 ThrowMsg(NullPointerException, "Private object not initialized");
338 TZDatePtr tzDate(privateObject->getObject());
339 std::string timezone = tzDate->getTimezone();
340 TimeUtilConverter converter(context);
342 return converter.toJSValueRef(timezone);
343 } Catch(NullPointerException) {
344 LoggerE("Exception: " << _rethrown_exception.GetMessage());
345 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
346 } Catch(WrtDeviceApis::Commons::UnknownException) {
347 LoggerE("Exception: " << _rethrown_exception.GetMessage());
348 } Catch (InvalidArgumentException) {
349 LoggerE("Exception: " << _rethrown_exception.GetMessage());
350 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
351 } Catch (PlatformException) {
352 LoggerE("Exception: " << _rethrown_exception.GetMessage());
355 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
358 JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
359 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
363 ArgumentValidator validator(context, argumentCount, arguments);
364 std::string timezone = validator.toString(0);
366 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
367 if (!privateObject) {
368 LoggerE("Private object is not set.");
369 ThrowMsg(NullPointerException, "Private object not initialized");
372 TZDatePtr tzDate(privateObject->getObject());
373 return createJSObject(context, tzDate->getTime(), timezone);
374 } catch(const BasePlatformException& err){
375 return JSWebAPIException::throwException(context, exception, err);
376 } Catch(NullPointerException) {
377 LoggerE("Exception: " << _rethrown_exception.GetMessage());
378 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
379 } Catch(WrtDeviceApis::Commons::UnknownException) {
380 LoggerE("Exception: " << _rethrown_exception.GetMessage());
381 } Catch (InvalidArgumentException) {
382 LoggerE("Exception: " << _rethrown_exception.GetMessage());
383 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
384 } Catch(ConversionException) {
385 LoggerE("Exception: " << _rethrown_exception.GetMessage());
386 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
387 } Catch (PlatformException) {
388 LoggerE("Exception: " << _rethrown_exception.GetMessage());
391 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
394 JSValueRef JSTZDate::diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
397 ArgumentValidator validator(context, argumentCount, arguments);
398 if (!validator.toObject(0, JSTZDate::getClassRef(), false))
399 ThrowMsg(ConversionException, "Parameter is not TZDate");
401 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
402 if (!privateObject) {
403 LoggerE("Private object is not set.");
404 ThrowMsg(NullPointerException, "Private object not initialized");
406 TimeUtilConverter converter(context);
407 TZDatePtr tzDate(privateObject->getObject());
408 long long cmpResult = tzDate->difference(converter.getPropertiesInTZDate(arguments[0]));
414 return converter.toJSValueRef(true);
416 return converter.toJSValueRef(false);
421 return converter.toJSValueRef(true);
423 return converter.toJSValueRef(false);
428 return converter.toJSValueRef(true);
430 return converter.toJSValueRef(false);
434 return converter.makeMillisecondDurationObject(cmpResult);
438 JSValueRef JSTZDate::difference(JSContextRef context, JSObjectRef function,
439 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
443 return diffTZDate(context, thisObject, argumentCount, arguments, exception, DIFFERENCE);
444 } catch(const BasePlatformException& err){
445 return JSWebAPIException::throwException(context, exception, err);
446 } Catch(InvalidArgumentException) {
447 LoggerE("Exception: " << _rethrown_exception.GetMessage());
448 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
449 } Catch(NullPointerException) {
450 LoggerE("Exception: " << _rethrown_exception.GetMessage());
451 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
452 } Catch(WrtDeviceApis::Commons::UnknownException) {
453 LoggerE("Exception: " << _rethrown_exception.GetMessage());
454 } Catch(ConversionException) {
455 LoggerE("Exception: " << _rethrown_exception.GetMessage());
456 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
457 } Catch (PlatformException) {
458 LoggerE("Exception: " << _rethrown_exception.GetMessage());
461 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
464 JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
465 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
469 return diffTZDate(context, thisObject, argumentCount, arguments, exception, EQUALSTO);
470 } catch(const BasePlatformException& err){
471 return JSWebAPIException::throwException(context, exception, err);
472 } Catch(NullPointerException) {
473 LoggerE("Exception: " << _rethrown_exception.GetMessage());
474 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
475 } Catch(WrtDeviceApis::Commons::UnknownException) {
476 LoggerE("Exception: " << _rethrown_exception.GetMessage());
477 } Catch (InvalidArgumentException) {
478 LoggerE("Exception: " << _rethrown_exception.GetMessage());
479 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
480 } Catch(ConversionException) {
481 LoggerE("Exception: " << _rethrown_exception.GetMessage());
482 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
483 } Catch (PlatformException) {
484 LoggerE("Exception: " << _rethrown_exception.GetMessage());
486 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
489 JSValueRef JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
490 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
491 LoggerD("earlierThan entered");
494 return diffTZDate(context, thisObject, argumentCount, arguments, exception, EARLIERTHAN);
495 } catch(const BasePlatformException& err){
496 return JSWebAPIException::throwException(context, exception, err);
497 } Catch(NullPointerException) {
498 LoggerE("Exception: " << _rethrown_exception.GetMessage());
499 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
500 } Catch(WrtDeviceApis::Commons::UnknownException) {
501 LoggerE("Exception: " << _rethrown_exception.GetMessage());
502 } Catch (InvalidArgumentException) {
503 LoggerE("Exception: " << _rethrown_exception.GetMessage());
504 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
505 } Catch(ConversionException) {
506 LoggerE("Exception: " << _rethrown_exception.GetMessage());
507 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
508 } Catch (PlatformException) {
509 LoggerE("Exception: " << _rethrown_exception.GetMessage());
511 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
515 JSValueRef JSTZDate::laterThan(JSContextRef context, JSObjectRef function,
516 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
518 LoggerD("laterThan entered");
521 return diffTZDate(context, thisObject, argumentCount, arguments, exception, LATERTHAN);
522 } catch(const BasePlatformException& err){
523 return JSWebAPIException::throwException(context, exception, err);
524 } Catch(NullPointerException) {
525 LoggerE("Exception: " << _rethrown_exception.GetMessage());
526 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
527 } Catch(WrtDeviceApis::Commons::UnknownException) {
528 LoggerE("Exception: " << _rethrown_exception.GetMessage());
529 } Catch (InvalidArgumentException) {
530 LoggerE("Exception: " << _rethrown_exception.GetMessage());
531 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
532 } Catch(ConversionException) {
533 LoggerE("Exception: " << _rethrown_exception.GetMessage());
534 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
535 } Catch (PlatformException) {
536 LoggerE("Exception: " << _rethrown_exception.GetMessage());
538 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
542 JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
543 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
545 LoggerD("addDuration entered");
547 TimeUtilConverter converter(context);
549 DurationProperties duration;
550 if (argumentCount == 0)
551 duration= converter.getDurationPropertis(JSValueMakeUndefined(context));
553 duration= converter.getDurationPropertis(arguments[0]);
555 LoggerD("unit : " << duration.unit << " Length:" << duration.length);
556 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
557 if (!privateObject) {
558 LoggerE("Private object is not set.");
559 ThrowMsg(NullPointerException, "Private object not initialized");
562 TZDatePtr tzDate(privateObject->getObject());
563 TZDateProperties result = tzDate->addDuration(duration);
565 return (static_cast<JSValueRef>(createJSObject(context, result)));
566 } Catch(NullPointerException) {
567 LoggerE("Exception: " << _rethrown_exception.GetMessage());
568 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
569 } Catch(WrtDeviceApis::Commons::UnknownException) {
570 LoggerE("Exception: " << _rethrown_exception.GetMessage());
571 } Catch (InvalidArgumentException) {
572 LoggerE("Exception: " << _rethrown_exception.GetMessage());
573 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
574 } Catch(ConversionException) {
575 LoggerE("Exception: " << _rethrown_exception.GetMessage());
576 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
577 } Catch (PlatformException) {
578 LoggerE("Exception: " << _rethrown_exception.GetMessage());
579 } Catch (OutOfRangeException) {
580 LoggerE("Exception: " << _rethrown_exception.GetMessage());
581 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "The result is beyond the scope that TZDate can handle.");
584 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
587 JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
588 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
590 LoggerD("toUTC entered");
592 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
593 if (!privateObject) {
594 LoggerE("Private object is not set.");
595 ThrowMsg(NullPointerException, "Private object not initialized");
598 TZDatePtr tzDate(privateObject->getObject());
599 return createJSObject(context, tzDate->getTime(), tzDate->getUTCTimezoneName());
600 } Catch(NullPointerException) {
601 LoggerE("Exception: " << _rethrown_exception.GetMessage());
602 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
603 } Catch(WrtDeviceApis::Commons::UnknownException) {
604 LoggerE("Exception: " << _rethrown_exception.GetMessage());
605 } Catch (InvalidArgumentException) {
606 LoggerE("Exception: " << _rethrown_exception.GetMessage());
607 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
608 } Catch (PlatformException) {
609 LoggerE("Exception: " << _rethrown_exception.GetMessage());
611 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
615 JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
616 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
618 LoggerD("toLocalTimezone entered");
620 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
621 if (!privateObject) {
622 LoggerE("Private object is not set.");
623 ThrowMsg(NullPointerException, "Private object not initialized");
626 TZDatePtr tzDate(privateObject->getObject());
627 return createJSObject(context, tzDate->getTime(), tzDate->getLocalTimezoneName());
628 } Catch(NullPointerException) {
629 LoggerE("Exception: " << _rethrown_exception.GetMessage());
630 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
631 } Catch(WrtDeviceApis::Commons::UnknownException) {
632 LoggerE("Exception: " << _rethrown_exception.GetMessage());
633 } Catch (InvalidArgumentException) {
634 LoggerE("Exception: " << _rethrown_exception.GetMessage());
635 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
636 } Catch (PlatformException) {
637 LoggerE("Exception: " << _rethrown_exception.GetMessage());
639 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
642 JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef function,
643 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
646 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
647 if (!privateObject) {
648 LoggerE("Private object is not set.");
649 ThrowMsg(NullPointerException, "Private object not initialized");
652 TimeUtilConverter converter(context);
654 TZDatePtr tzDate(privateObject->getObject());
655 std::string result = tzDate->toDateString(true);
656 return converter.toJSValueRef(result);
657 } Catch(NullPointerException) {
658 LoggerE("Exception: " << _rethrown_exception.GetMessage());
659 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
660 } Catch(WrtDeviceApis::Commons::UnknownException) {
661 LoggerE("Exception: " << _rethrown_exception.GetMessage());
662 } Catch (InvalidArgumentException) {
663 LoggerE("Exception: " << _rethrown_exception.GetMessage());
664 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
665 } Catch (PlatformException) {
666 LoggerE("Exception: " << _rethrown_exception.GetMessage());
669 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
672 JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef function,
673 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
676 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
677 if (!privateObject) {
678 LoggerE("Private object is not set.");
679 ThrowMsg(NullPointerException, "Private object not initialized");
682 TimeUtilConverter converter(context);
684 TZDatePtr tzDate(privateObject->getObject());
685 std::string result = tzDate->toTimeString(true);
686 return converter.toJSValueRef(result);
687 } Catch(NullPointerException) {
688 LoggerE("Exception: " << _rethrown_exception.GetMessage());
689 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
690 } Catch(WrtDeviceApis::Commons::UnknownException) {
691 LoggerE("Exception: " << _rethrown_exception.GetMessage());
692 } Catch (InvalidArgumentException) {
693 LoggerE("Exception: " << _rethrown_exception.GetMessage());
694 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
695 } Catch (PlatformException) {
696 LoggerE("Exception: " << _rethrown_exception.GetMessage());
699 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
702 JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
703 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
706 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
707 if (!privateObject) {
708 LoggerE("Private object is not set.");
709 ThrowMsg(NullPointerException, "Private object not initialized");
712 TimeUtilConverter converter(context);
714 TZDatePtr tzDate(privateObject->getObject());
715 std::string result = tzDate->toString(true);
716 return converter.toJSValueRef(result);
717 } Catch(NullPointerException) {
718 LoggerE("Exception: " << _rethrown_exception.GetMessage());
719 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
720 } Catch(WrtDeviceApis::Commons::UnknownException) {
721 LoggerE("Exception: " << _rethrown_exception.GetMessage());
722 } Catch (InvalidArgumentException) {
723 LoggerE("Exception: " << _rethrown_exception.GetMessage());
724 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
725 } Catch (PlatformException) {
726 LoggerE("Exception: " << _rethrown_exception.GetMessage());
729 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
732 JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
733 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
736 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
737 if (!privateObject) {
738 LoggerE("Private object is not set.");
739 ThrowMsg(NullPointerException, "Private object not initialized");
742 TimeUtilConverter converter(context);
744 TZDatePtr tzDate(privateObject->getObject());
745 std::string result = tzDate->toDateString();
746 return converter.toJSValueRef(result);
747 } Catch(NullPointerException) {
748 LoggerE("Exception: " << _rethrown_exception.GetMessage());
749 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
750 } Catch(WrtDeviceApis::Commons::UnknownException) {
751 LoggerE("Exception: " << _rethrown_exception.GetMessage());
752 } Catch (InvalidArgumentException) {
753 LoggerE("Exception: " << _rethrown_exception.GetMessage());
754 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
755 } Catch (PlatformException) {
756 LoggerE("Exception: " << _rethrown_exception.GetMessage());
759 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
762 JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
763 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
766 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
767 if (!privateObject) {
768 LoggerE("Private object is not set.");
769 ThrowMsg(NullPointerException, "Private object not initialized");
772 TimeUtilConverter converter(context);
774 TZDatePtr tzDate(privateObject->getObject());
775 std::string result = tzDate->toTimeString();
776 return converter.toJSValueRef(result);
777 } Catch(NullPointerException) {
778 LoggerE("Exception: " << _rethrown_exception.GetMessage());
779 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
780 } Catch(WrtDeviceApis::Commons::UnknownException) {
781 LoggerE("Exception: " << _rethrown_exception.GetMessage());
782 } Catch (InvalidArgumentException) {
783 LoggerE("Exception: " << _rethrown_exception.GetMessage());
784 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
785 } Catch (PlatformException) {
786 LoggerE("Exception: " << _rethrown_exception.GetMessage());
789 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
793 JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
794 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
797 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
798 if (!privateObject) {
799 LoggerE("Private object is not set.");
800 ThrowMsg(NullPointerException, "Private object not initialized");
803 TimeUtilConverter converter(context);
805 TZDatePtr tzDate(privateObject->getObject());
806 std::string result = tzDate->toString();
807 return converter.toJSValueRef(result);
808 } Catch(NullPointerException) {
809 LoggerE("Exception: " << _rethrown_exception.GetMessage());
810 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
811 } Catch(WrtDeviceApis::Commons::UnknownException) {
812 LoggerE("Exception: " << _rethrown_exception.GetMessage());
813 } Catch (InvalidArgumentException) {
814 LoggerE("Exception: " << _rethrown_exception.GetMessage());
815 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
816 } Catch (PlatformException) {
817 LoggerE("Exception: " << _rethrown_exception.GetMessage());
820 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
823 JSValueRef JSTZDate::getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
824 JSValueRef * exception) {
827 TZDate::TZDateFields dateFields = TZDate::TZDATE_DATE;
828 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
831 JSValueRef JSTZDate::getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
832 JSValueRef * exception) {
835 TZDate::TZDateFields dateFields = TZDate::TZDATE_DAY_OF_WEEK;
836 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
839 JSValueRef JSTZDate::getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
840 JSValueRef * exception) {
843 TZDate::TZDateFields dateFields = TZDate::TZDATE_YEAR;
844 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
847 JSValueRef JSTZDate::getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
848 JSValueRef * exception) {
851 TZDate::TZDateFields dateFields = TZDate::TZDATE_HOUR_OF_DAY;
852 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
855 JSValueRef JSTZDate::getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
856 JSValueRef * exception) {
859 TZDate::TZDateFields dateFields = TZDate::TZDATE_MILLISECOND;
860 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
861 } //getMilliseconds()
863 JSValueRef JSTZDate::getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
864 JSValueRef * exception) {
867 TZDate::TZDateFields dateFields = TZDate::TZDATE_MINUTE;
868 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
871 JSValueRef JSTZDate::getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
872 JSValueRef * exception) {
874 TZDate::TZDateFields dateFields = TZDate::TZDATE_MONTH;
875 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
878 JSValueRef JSTZDate::getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
879 JSValueRef * exception) {
882 TZDate::TZDateFields dateFields = TZDate::TZDATE_SECOND;
883 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
886 JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
887 TZDate::TZDateFields dateFields) {
889 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
891 if (privateObject == NULL) {
892 LoggerE(">>> NULL Exception");
893 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
896 TZDatePtr tzDate(privateObject->getObject());
897 long retVal = tzDate->get(dateFields);
899 TimeUtilConverter converter(context);
900 LoggerD(">>> retVal:" << retVal);
901 return converter.toJSValueRef(static_cast<int> (retVal));
902 } Catch(NullPointerException) {
903 LoggerE("Exception: " << _rethrown_exception.GetMessage());
904 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
905 } Catch(WrtDeviceApis::Commons::UnknownException) {
906 LoggerE("Exception: " << _rethrown_exception.GetMessage());
907 } Catch (InvalidArgumentException) {
908 LoggerE("Exception: " << _rethrown_exception.GetMessage());
909 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
910 } Catch (PlatformException) {
911 LoggerE("Exception: " << _rethrown_exception.GetMessage());
914 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
917 JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
918 JSValueRef * exception) {
921 TZDate::TZDateFields dateFields = TZDate::TZDATE_DATE;
924 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
925 } catch(const BasePlatformException& err){
926 return JSWebAPIException::throwException(context, exception, err);
927 } Catch(NullPointerException) {
928 LoggerE("Exception: " << _rethrown_exception.GetMessage());
929 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
930 } Catch(WrtDeviceApis::Commons::UnknownException) {
931 LoggerE("Exception: " << _rethrown_exception.GetMessage());
932 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
933 } Catch (InvalidArgumentException) {
934 LoggerE("Exception: " << _rethrown_exception.GetMessage());
935 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
936 } Catch(ConversionException) {
937 LoggerE("Exception: " << _rethrown_exception.GetMessage());
938 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
939 } Catch (PlatformException) {
940 LoggerE("Exception: " << _rethrown_exception.GetMessage());
941 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
944 return JSValueMakeNull(context);
947 JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
948 JSValueRef * exception) {
951 TZDate::TZDateFields dateFields = TZDate::TZDATE_YEAR;
954 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
955 } catch(const BasePlatformException& err){
956 return JSWebAPIException::throwException(context, exception, err);
957 } Catch(NullPointerException) {
958 LoggerE("Exception: " << _rethrown_exception.GetMessage());
959 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
960 } Catch(WrtDeviceApis::Commons::UnknownException) {
961 LoggerE("Exception: " << _rethrown_exception.GetMessage());
962 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
963 } Catch (InvalidArgumentException) {
964 LoggerE("Exception: " << _rethrown_exception.GetMessage());
965 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
966 } Catch(ConversionException) {
967 LoggerE("Exception: " << _rethrown_exception.GetMessage());
968 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
969 } Catch (PlatformException) {
970 LoggerE("Exception: " << _rethrown_exception.GetMessage());
971 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
974 return JSValueMakeNull(context);
977 JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
978 JSValueRef * exception) {
981 TZDate::TZDateFields dateFields = TZDate::TZDATE_HOUR_OF_DAY;
984 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
985 } catch(const BasePlatformException& err){
986 return JSWebAPIException::throwException(context, exception, err);
987 }Catch(NullPointerException) {
988 LoggerE("Exception: " << _rethrown_exception.GetMessage());
989 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
990 } Catch(WrtDeviceApis::Commons::UnknownException) {
991 LoggerE("Exception: " << _rethrown_exception.GetMessage());
992 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
993 } Catch (InvalidArgumentException) {
994 LoggerE("Exception: " << _rethrown_exception.GetMessage());
995 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
996 } Catch(ConversionException) {
997 LoggerE("Exception: " << _rethrown_exception.GetMessage());
998 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
999 } Catch (PlatformException) {
1000 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1001 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1004 return JSValueMakeNull(context);
1007 JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1008 JSValueRef * exception) {
1011 TZDate::TZDateFields dateFields = TZDate::TZDATE_MILLISECOND;
1014 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1015 } catch(const BasePlatformException& err){
1016 return JSWebAPIException::throwException(context, exception, err);
1017 }Catch(NullPointerException) {
1018 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1019 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1020 } Catch(WrtDeviceApis::Commons::UnknownException) {
1021 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1022 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1023 } Catch (InvalidArgumentException) {
1024 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1025 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1026 } Catch(ConversionException) {
1027 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1028 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1029 } Catch (PlatformException) {
1030 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1031 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1034 return JSValueMakeNull(context);
1035 } //setMilliseconds()
1037 JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1038 JSValueRef * exception) {
1041 TZDate::TZDateFields dateFields = TZDate::TZDATE_MINUTE;
1044 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1045 } catch(const BasePlatformException& err){
1046 return JSWebAPIException::throwException(context, exception, err);
1047 }Catch(NullPointerException) {
1048 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1049 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1050 } Catch(WrtDeviceApis::Commons::UnknownException) {
1051 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1052 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1053 } Catch (InvalidArgumentException) {
1054 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1055 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1056 } Catch(ConversionException) {
1057 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1058 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1059 } Catch (PlatformException) {
1060 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1061 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1064 return JSValueMakeNull(context);
1067 JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1068 JSValueRef * exception) {
1071 TZDate::TZDateFields dateFields = TZDate::TZDATE_MONTH;
1074 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1075 } catch(const BasePlatformException& err){
1076 return JSWebAPIException::throwException(context, exception, err);
1077 }Catch(NullPointerException) {
1078 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1079 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1080 } Catch(WrtDeviceApis::Commons::UnknownException) {
1081 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1082 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1083 } Catch (InvalidArgumentException) {
1084 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1085 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1086 } Catch(ConversionException) {
1087 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1088 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1089 } Catch (PlatformException) {
1090 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1091 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1094 return JSValueMakeNull(context);
1097 JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1098 JSValueRef * exception) {
1101 TZDate::TZDateFields dateFields = TZDate::TZDATE_SECOND;
1104 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1105 } catch(const BasePlatformException& err){
1106 return JSWebAPIException::throwException(context, exception, err);
1107 }Catch(NullPointerException) {
1108 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1109 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1110 } Catch(WrtDeviceApis::Commons::UnknownException) {
1111 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1112 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1113 } Catch (InvalidArgumentException) {
1114 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1115 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1116 } Catch(ConversionException) {
1117 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1118 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1119 } Catch (PlatformException) {
1120 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1121 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1124 return JSValueMakeNull(context);
1128 JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1129 JSValueRef * exception, TZDate::TZDateFields dateFields) {
1130 ArgumentValidator validator(context, argumentCount, arguments);
1131 long data = validator.toLong(0);
1133 if ((dateFields == TZDate::TZDATE_YEAR) && (data < 0))
1134 ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1136 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1138 if (privateObject == NULL) {
1139 LoggerE(">>> NULL Exception");
1140 ThrowMsg(NullPointerException, "privateObject is NULL");
1143 TZDatePtr tzDate(privateObject->getObject());
1144 tzDate->set(dateFields,data);
1146 return JSValueMakeNull(context);
1149 JSValueRef JSTZDate::getUTCDate(JSContextRef context, JSObjectRef function,
1150 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1152 return getUTCTZDateValue(context, thisObject, argumentCount, TZDate::TZDATE_DATE, exception);
1155 JSValueRef JSTZDate::getUTCDay(JSContextRef context, JSObjectRef function,
1156 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1158 return getUTCTZDateValue(context, thisObject, argumentCount, TZDate::TZDATE_DAY_OF_WEEK, exception);
1161 JSValueRef JSTZDate::getUTCFullYear(JSContextRef context, JSObjectRef function,
1162 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1164 return getUTCTZDateValue(context, thisObject, argumentCount, TZDate::TZDATE_YEAR, exception);
1167 JSValueRef JSTZDate::getUTCHours(JSContextRef context, JSObjectRef function,
1168 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1170 return getUTCTZDateValue(context, thisObject, argumentCount, TZDate::TZDATE_HOUR_OF_DAY, exception);
1173 JSValueRef JSTZDate::getUTCMilliseconds(JSContextRef context, JSObjectRef function,
1174 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1176 return getUTCTZDateValue(context, thisObject, argumentCount, TZDate::TZDATE_MILLISECOND, exception);
1179 JSValueRef JSTZDate::getUTCMinutes(JSContextRef context, JSObjectRef function,
1180 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1182 return getUTCTZDateValue(context, thisObject, argumentCount, TZDate::TZDATE_MINUTE, exception);
1185 JSValueRef JSTZDate::getUTCMonth(JSContextRef context, JSObjectRef function,
1186 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1188 return getUTCTZDateValue(context, thisObject, argumentCount, TZDate::TZDATE_MONTH, exception);
1191 JSValueRef JSTZDate::getUTCSeconds(JSContextRef context, JSObjectRef function,
1192 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1194 return getUTCTZDateValue(context, thisObject, argumentCount, TZDate::TZDATE_SECOND, exception);
1197 JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, TZDate::TZDateFields DateFields, JSValueRef * exception) {
1200 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1201 if (!privateObject) {
1202 LoggerE("Private object is not set.");
1203 ThrowMsg(NullPointerException, "Private object not initialized");
1206 TimeUtilConverter converter(context);
1208 TZDatePtr tzDate(privateObject->getObject());
1209 long result = tzDate->getUTC(DateFields);
1211 return converter.toJSValueRefLong(result);
1212 } Catch(NullPointerException) {
1213 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1214 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1215 } Catch(WrtDeviceApis::Commons::UnknownException) {
1216 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1217 } Catch (InvalidArgumentException) {
1218 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1219 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1220 } Catch (PlatformException) {
1221 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1224 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1227 JSValueRef JSTZDate::setUTCDate(JSContextRef context, JSObjectRef function,
1228 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1231 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, TZDate::TZDATE_DATE, exception);
1234 JSValueRef JSTZDate::setUTCFullYear(JSContextRef context, JSObjectRef function,
1235 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1238 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, TZDate::TZDATE_YEAR, exception);
1241 JSValueRef JSTZDate::setUTCHours(JSContextRef context, JSObjectRef function,
1242 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1245 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, TZDate::TZDATE_HOUR_OF_DAY, exception);
1248 JSValueRef JSTZDate::setUTCMilliseconds(JSContextRef context, JSObjectRef function,
1249 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1252 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, TZDate::TZDATE_MILLISECOND, exception);
1255 JSValueRef JSTZDate::setUTCMinutes(JSContextRef context, JSObjectRef function,
1256 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1259 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, TZDate::TZDATE_MINUTE, exception);
1262 JSValueRef JSTZDate::setUTCMonth(JSContextRef context, JSObjectRef function,
1263 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1266 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, TZDate::TZDATE_MONTH, exception);
1269 JSValueRef JSTZDate::setUTCSeconds(JSContextRef context, JSObjectRef function,
1270 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1273 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, TZDate::TZDATE_SECOND, exception);
1276 JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject,
1277 size_t argumentCount, const JSValueRef arguments[], TZDate::TZDateFields dateFields, JSValueRef * exception) {
1280 TimeUtilConverter converter(context);
1283 if (argumentCount == 0)
1284 data = converter.toLong(JSValueMakeUndefined(context));
1286 data = converter.toLong(arguments[0]);
1288 if ((dateFields == TZDate::TZDATE_YEAR) && (data < 0))
1289 ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1291 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1292 if (!privateObject) {
1293 LoggerE("Private object is not set.");
1294 ThrowMsg(NullPointerException, "Private object not initialized");
1297 TZDatePtr tzDate(privateObject->getObject());
1298 tzDate->setUTC(dateFields, data);
1300 return JSValueMakeNull(context);
1301 } Catch(NullPointerException) {
1302 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1303 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1304 } Catch(WrtDeviceApis::Commons::UnknownException) {
1305 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1306 } Catch (InvalidArgumentException) {
1307 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1308 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1309 } Catch(ConversionException) {
1310 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1311 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1312 } Catch (PlatformException) {
1313 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1316 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1319 JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1322 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1323 if (!privateObject) {
1324 LoggerE("Private object is not set.");
1325 ThrowMsg(NullPointerException, "Private object not initialized");
1328 TimeUtilConverter converter(context);
1330 TZDatePtr tzDate(privateObject->getObject());
1334 return converter.toJSValueRef(tzDate->getTimezoneAbbreviation());
1335 } Catch(NullPointerException) {
1336 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1337 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1338 } Catch(WrtDeviceApis::Commons::UnknownException) {
1339 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1340 } Catch (InvalidArgumentException) {
1341 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1342 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1343 } Catch (PlatformException) {
1344 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1346 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1349 JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1353 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1354 if (!privateObject) {
1355 LoggerE("Private object is not set.");
1356 ThrowMsg(NullPointerException, "Private object not initialized");
1359 TimeUtilConverter converter(context);
1361 TZDatePtr tzDate(privateObject->getObject());
1363 return converter.toJSValueRefLong(tzDate->secondsFromUTC());
1364 } Catch(NullPointerException) {
1365 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1366 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1367 } Catch(WrtDeviceApis::Commons::UnknownException) {
1368 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1369 } Catch (InvalidArgumentException) {
1370 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1371 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1372 } Catch (PlatformException) {
1373 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1375 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1377 JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1380 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1381 if (!privateObject) {
1382 LoggerE("Private object is not set.");
1383 ThrowMsg(NullPointerException, "Private object not initialized");
1386 TimeUtilConverter converter(context);
1388 TZDatePtr tzDate(privateObject->getObject());
1390 return converter.toJSValueRef(tzDate->isDST());
1391 } Catch(NullPointerException) {
1392 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1393 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1394 } Catch(WrtDeviceApis::Commons::UnknownException) {
1395 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1396 } Catch (InvalidArgumentException) {
1397 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1398 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1399 } Catch (PlatformException) {
1400 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1402 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1405 JSValueRef JSTZDate::getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1409 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1410 if (!privateObject) {
1411 LoggerE("Private object is not set.");
1412 ThrowMsg(NullPointerException, "Private object not initialized");
1415 TimeUtilConverter converter(context);
1417 TZDatePtr tzDate(privateObject->getObject());
1419 TZDateProperties resultDate = tzDate->getDSTTransition(TZDate::PREV_TRANSITION);
1420 if (resultDate.timezone == "")
1421 return JSValueMakeNull(context);
1423 return createJSObject(context, resultDate);
1424 } Catch(NullPointerException) {
1425 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1426 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1427 } Catch(WrtDeviceApis::Commons::UnknownException) {
1428 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1429 } Catch (InvalidArgumentException) {
1430 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1431 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1432 } Catch (PlatformException) {
1433 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1435 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1438 JSValueRef JSTZDate::getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1442 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1443 if (!privateObject) {
1444 LoggerE("Private object is not set.");
1445 ThrowMsg(NullPointerException, "Private object not initialized");
1448 TimeUtilConverter converter(context);
1450 TZDatePtr tzDate(privateObject->getObject());
1452 TZDateProperties resultDate = tzDate->getDSTTransition(TZDate::NEXT_TRANSITION);
1453 if (resultDate.timezone == "")
1454 return JSValueMakeNull(context);
1456 return createJSObject(context, resultDate);
1457 } Catch(NullPointerException) {
1458 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1459 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1460 } Catch(WrtDeviceApis::Commons::UnknownException) {
1461 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1462 } Catch (InvalidArgumentException) {
1463 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1464 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1465 } Catch (PlatformException) {
1466 LoggerE("Exception: " << _rethrown_exception.GetMessage());
1468 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");