2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dpl/log/log.h>
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>
30 #include <API/TimeUtil/DurationProperties.h>
31 #include <API/TimeUtil/TimeUtilFactory.h>
34 #include "TimeUtilConverter.h"
35 #include "plugin_config.h"
37 using namespace TizenApis::Api::TimeUtil;
38 using namespace TizenApis::Commons;
39 using namespace WrtDeviceApis::Commons;
40 using namespace WrtDeviceApis::CommonsJavaScript;
42 #define min(a,b) (((a) < (b)) ? (a) : (b))
44 #define TIZEN10_TZDATE_ATTRIBUTENAME "TZDate"
49 JSClassDefinition JSTZDate::m_classInfo =
52 kJSClassAttributeNone,
53 TIZEN10_TZDATE_ATTRIBUTENAME,
62 NULL, //DeleteProperty,
63 NULL, //GetPropertyNames,
64 NULL, //CallAsFunction,
65 constructor, //CallAsConstructor,
66 hasInstance, //HasInstance,
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},
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},
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},
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},
105 {"getTimezone", JSTZDate::getTimezone, kJSPropertyAttributeNone},
106 {"toTimezone", JSTZDate::toTimezone, kJSPropertyAttributeNone},
107 {"toLocalTimezone", JSTZDate::toLocalTimezone, kJSPropertyAttributeNone},
108 {"toUTC", JSTZDate::toUTC, kJSPropertyAttributeNone},
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},
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},
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},
131 JSClassRef JSTZDate::m_jsClassRef = JSClassCreate(JSTZDate::getClassInfo());
133 JSObjectRef JSTZDate::createJSObject(JSContextRef context) {
135 ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject();
136 TZDatePrivObject *priv = new TZDatePrivObject(context, TZDate);
138 ThrowMsg(NullPointerException, "Can not new an object");
141 return JSObjectMake(context, getClassRef(), priv);
144 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const std::string &timezone) {
147 return createJSObject(context);
149 ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject(timezone);
150 TZDatePrivObject *priv = new TZDatePrivObject(context, TZDate);
152 ThrowMsg(NullPointerException, "Can not new an object");
155 return JSObjectMake(context, getClassRef(), priv);
158 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const TZDateProperties &properties) {
160 ITZDatePtr TZDate = TimeUtilFactory::getInstance().createTZDateObject(properties);
162 TZDatePrivObject *priv = new TZDatePrivObject(context, TZDate);
164 ThrowMsg(NullPointerException, "Can not new an object");
167 return JSObjectMake(context, getClassRef(), priv);
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) {
173 TZDateProperties props;
178 props.minutes = minutes;
179 props.seconds = seconds;
180 props.milliseconds = milliseconds;
181 props.timezone = timezone;
183 return createJSObject(context, props);
187 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const time_t localTime, const std::string &timezone) {
190 return createJSObject(context, localTime, 0, timezone);
193 JSObjectRef JSTZDate::createJSObject(JSContextRef context, const time_t localTime, const long msec, const std::string &timezone) {
196 struct tm *tm = localtime(&localTime);
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);
201 void JSTZDate::initialize(JSContextRef context, JSObjectRef object)
203 LogDebug("entered Nothing to do.");
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)) {
215 void JSTZDate::finalize(JSObjectRef object)
217 LogDebug( "entered" );
218 TZDatePrivObject *priv =
219 static_cast<TZDatePrivObject*>( JSObjectGetPrivate( object ) ) ;
223 JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
226 TZDateProperties prop;
227 TimeUtilConverter converter(ctx);
229 TZDatePrivObject* mainPriv = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(constructor));
230 JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
232 if (argumentCount > 8) {
233 LogError("Wrong argument count");
234 ThrowMsg(InvalidArgumentException, "Wrong TZDate argumentCount");
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]);
248 if (JSValueIsNull(ctx, arguments[0]))
249 return createJSObject(global_context, timezone);
252 date = converter.toDateTimeT(arguments[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);
264 return createJSObject(global_context, date, timezone);
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");
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");
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");
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");
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");
298 if (!JSValueIsNull(ctx, arguments[7]))
299 prop.timezone = converter.toString(arguments[7]);
305 return createJSObject(global_context, prop);
307 ThrowMsg(InvalidArgumentException, "Wrong TZDate argumentCount");
308 } Catch(ConversionException) {
309 LogDebug("Wrong conversion");
310 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
312 } Catch (InvalidArgumentException) {
313 LogError("Exception: " << _rethrown_exception.GetMessage());
314 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
316 } Catch (PlatformException) {
317 LogError("Exception: " << _rethrown_exception.GetMessage());
318 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
320 } Catch (WrtDeviceApis::Commons::Exception) {
321 LogWarning("Trying to get incorrect value");
322 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
325 *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
328 const JSClassRef JSTZDate::getClassRef()
331 m_jsClassRef = JSClassCreate(&m_classInfo);
336 const JSClassDefinition* JSTZDate::getClassInfo()
341 bool JSTZDate::hasInstance(JSContextRef context,
342 JSObjectRef constructor,
343 JSValueRef possibleInstance,
344 JSValueRef* exception)
346 return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
349 JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
350 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
354 if (argumentCount != 0) {
355 LogError("Wrong argument count");
356 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
365 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
366 privateObject->getContext(),
367 TIMEUTIL_FUNCTION_API_READ_FUNCS);
368 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
370 ITZDatePtr TZDate(privateObject->getObject());
371 std::string timezone = TZDate->getTimezone();
372 TimeUtilConverter converter(context);
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");
389 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
392 JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
393 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
396 TimeUtilConverter converter(context);
399 if (argumentCount != 1) {
400 LogError("Wrong TZDate parameters count");
401 ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
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");
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");
416 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
417 privateObject->getContext(),
418 TIMEUTIL_FUNCTION_API_READ_FUNCS);
419 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
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");
441 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
444 JSValueRef JSTZDate::diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
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");
453 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
454 privateObject->getContext(),
455 TIMEUTIL_FUNCTION_API_READ_FUNCS);
457 TimeUtilConverter converter(context);
459 if (argumentCount != 1) {
460 LogError("Wrong TZDate parameters count");
461 ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
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");
470 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
471 ITZDatePtr TZDate(privateObject->getObject());
472 long long cmpResult = TZDate->difference(converter.getPropertiesInTZDate(arguments[0]));
478 return converter.toJSValueRef(TRUE);
480 return converter.toJSValueRef(FALSE);
485 return converter.toJSValueRef(TRUE);
487 return converter.toJSValueRef(FALSE);
492 return converter.toJSValueRef(TRUE);
494 return converter.toJSValueRef(FALSE);
498 return converter.makeMillisecondDurationObject(cmpResult);
502 JSValueRef JSTZDate::difference(JSContextRef context, JSObjectRef function,
503 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
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");
525 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
528 JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
529 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
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");
550 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
553 JSValueRef JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
554 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
555 LogDebug("earlierThan entered");
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");
575 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
579 JSValueRef JSTZDate::laterThan(JSContextRef context, JSObjectRef function,
580 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
582 LogDebug("laterThan entered");
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");
602 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
606 JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
607 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
609 LogDebug("addDuration entered");
611 if (argumentCount != 1) {
612 LogError("Wrong argument count");
613 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
622 TimeUtilConverter converter(context);
624 DurationProperties duration = converter.getDurationPropertis(arguments[0]);
626 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
627 privateObject->getContext(),
628 TIMEUTIL_FUNCTION_API_READ_FUNCS);
629 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
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");
650 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
653 JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
654 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
656 LogDebug("toUTC entered");
658 if (argumentCount != 0) {
659 LogError("Wrong argument count");
660 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
669 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
670 privateObject->getContext(),
671 TIMEUTIL_FUNCTION_API_READ_FUNCS);
672 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
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");
690 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
694 JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
695 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
697 LogDebug("toLocalTimezone entered");
699 if (argumentCount != 0) {
700 LogError("Wrong argument count");
701 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
710 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
711 privateObject->getContext(),
712 TIMEUTIL_FUNCTION_API_READ_FUNCS);
713 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
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");
731 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
734 JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef function,
735 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
738 if (argumentCount != 0) {
739 LogError("Wrong argument count");
740 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
749 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
750 privateObject->getContext(),
751 TIMEUTIL_FUNCTION_API_READ_FUNCS);
752 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
754 TimeUtilConverter converter(context);
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");
773 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
776 JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef function,
777 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
780 if (argumentCount != 0) {
781 LogError("Wrong argument count");
782 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
791 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
792 privateObject->getContext(),
793 TIMEUTIL_FUNCTION_API_READ_FUNCS);
794 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
796 TimeUtilConverter converter(context);
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");
815 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
818 JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
819 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
822 if (argumentCount != 0) {
823 LogError("Wrong argument count");
824 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
833 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
834 privateObject->getContext(),
835 TIMEUTIL_FUNCTION_API_READ_FUNCS);
836 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
838 TimeUtilConverter converter(context);
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");
857 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
860 JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
861 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
864 if (argumentCount != 0) {
865 LogError("Wrong argument count");
866 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
875 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
876 privateObject->getContext(),
877 TIMEUTIL_FUNCTION_API_READ_FUNCS);
878 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
880 TimeUtilConverter converter(context);
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");
899 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
902 JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
903 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
906 if (argumentCount != 0) {
907 LogError("Wrong argument count");
908 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
917 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
918 privateObject->getContext(),
919 TIMEUTIL_FUNCTION_API_READ_FUNCS);
920 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
922 TimeUtilConverter converter(context);
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");
941 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
945 JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
946 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
949 if (argumentCount != 0) {
950 LogError("Wrong argument count");
951 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
960 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
961 privateObject->getContext(),
962 TIMEUTIL_FUNCTION_API_READ_FUNCS);
963 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
965 TimeUtilConverter converter(context);
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");
984 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
987 JSValueRef JSTZDate::getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
988 JSValueRef * exception) {
991 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
992 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
995 JSValueRef JSTZDate::getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
996 JSValueRef * exception) {
999 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DAY_OF_WEEK;
1000 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1003 JSValueRef JSTZDate::getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1004 JSValueRef * exception) {
1007 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
1008 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1011 JSValueRef JSTZDate::getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1012 JSValueRef * exception) {
1015 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
1016 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1019 JSValueRef JSTZDate::getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1020 JSValueRef * exception) {
1023 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
1024 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1025 } //getMilliseconds()
1027 JSValueRef JSTZDate::getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1028 JSValueRef * exception) {
1031 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
1032 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1035 JSValueRef JSTZDate::getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1036 JSValueRef * exception) {
1038 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
1039 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1042 JSValueRef JSTZDate::getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1043 JSValueRef * exception) {
1046 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
1047 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1050 JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
1051 ITZDate::TZDateFields dateFields) {
1053 if (argumentCount != 0) {
1054 LogError("Wrong argument count");
1055 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1058 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1060 if (privateObject == NULL) {
1061 LogError(">>> NULL Exception");
1062 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1065 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1066 privateObject->getContext(),
1067 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1068 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1070 ITZDatePtr tzDate(privateObject->getObject());
1071 long retVal = tzDate->get(dateFields);
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");
1090 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1093 JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1094 JSValueRef * exception) {
1097 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
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");
1118 return JSValueMakeNull(context);
1121 JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1122 JSValueRef * exception) {
1125 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
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");
1146 return JSValueMakeNull(context);
1149 JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1150 JSValueRef * exception) {
1153 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
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");
1174 return JSValueMakeNull(context);
1177 JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1178 JSValueRef * exception) {
1181 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
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");
1202 return JSValueMakeNull(context);
1203 } //setMilliseconds()
1205 JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1206 JSValueRef * exception) {
1209 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
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");
1230 return JSValueMakeNull(context);
1233 JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1234 JSValueRef * exception) {
1237 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
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");
1258 return JSValueMakeNull(context);
1261 JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1262 JSValueRef * exception) {
1265 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
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");
1286 return JSValueMakeNull(context);
1290 JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1291 JSValueRef * exception, ITZDate::TZDateFields dateFields) {
1293 if (argumentCount != 1) {
1294 LogError("Wrong parameters");
1295 ThrowMsg(InvalidArgumentException, "argumentIndex is bigger than argumentCount");
1298 TimeUtilConverter converter(context);
1300 if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
1301 || (!JSValueIsNumber(context, arguments[0])))
1302 ThrowMsg(ConversionException, "Invalid Argument");
1304 int data = converter.toInt(arguments[0]);
1306 if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
1307 ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1309 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1311 if (privateObject == NULL) {
1312 LogError(">>> NULL Exception");
1313 ThrowMsg(UnknownException, "privateObject is NULL");
1316 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1317 privateObject->getContext(),
1318 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1319 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1321 ITZDatePtr tzDate(privateObject->getObject());
1322 tzDate->set(dateFields, static_cast<long> (data));
1324 return JSValueMakeNull(context);
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);
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);
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);
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);
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);
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);
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);
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);
1375 JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, ITZDate::TZDateFields DateFields, JSValueRef * exception) {
1376 LogDebug("Entered");
1378 if (argumentCount != 0) {
1379 LogError("Wrong argument count");
1380 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
1389 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1390 privateObject->getContext(),
1391 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1392 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1394 TimeUtilConverter converter(context);
1396 ITZDatePtr TZDate(privateObject->getObject());
1397 long result = TZDate->getUTC(DateFields);
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");
1414 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1417 JSValueRef JSTZDate::setUTCDate(JSContextRef context, JSObjectRef function,
1418 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1419 LogDebug("Entered");
1421 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_DATE, exception);
1424 JSValueRef JSTZDate::setUTCFullYear(JSContextRef context, JSObjectRef function,
1425 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1426 LogDebug("Entered");
1428 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_YEAR, exception);
1431 JSValueRef JSTZDate::setUTCHours(JSContextRef context, JSObjectRef function,
1432 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1433 LogDebug("Entered");
1435 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_HOUR_OF_DAY, exception);
1438 JSValueRef JSTZDate::setUTCMilliseconds(JSContextRef context, JSObjectRef function,
1439 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1440 LogDebug("Entered");
1442 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MILLISECOND, exception);
1445 JSValueRef JSTZDate::setUTCMinutes(JSContextRef context, JSObjectRef function,
1446 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1447 LogDebug("Entered");
1449 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MINUTE, exception);
1452 JSValueRef JSTZDate::setUTCMonth(JSContextRef context, JSObjectRef function,
1453 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1454 LogDebug("Entered");
1456 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MONTH, exception);
1459 JSValueRef JSTZDate::setUTCSeconds(JSContextRef context, JSObjectRef function,
1460 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1461 LogDebug("Entered");
1463 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_SECOND, exception);
1466 JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject,
1467 size_t argumentCount, const JSValueRef arguments[], ITZDate::TZDateFields dateFields, JSValueRef * exception) {
1468 LogDebug("Entered");
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");
1476 if (argumentCount != 1) {
1477 LogError("Wrong TZDate parameters count");
1478 ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
1481 if (!JSValueIsNumber(context, arguments[0]))
1483 LogError("Wrong TZDate parameters");
1484 ThrowMsg(ConversionException, "Wrong TZDate parameters");
1487 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1488 privateObject->getContext(),
1489 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1490 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1492 TimeUtilConverter converter(context);
1494 long data = converter.FromJSValueReftolong(arguments[0]);
1496 if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
1497 ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1499 ITZDatePtr TZDate(privateObject->getObject());
1500 TZDate->setUTC(dateFields, data);
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");
1520 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1523 JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1524 LogDebug("entered");
1526 if (argumentCount != 0) {
1527 LogError("Wrong argument count");
1528 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
1537 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1538 privateObject->getContext(),
1539 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1540 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1542 TimeUtilConverter converter(context);
1544 ITZDatePtr tzDate(privateObject->getObject());
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");
1562 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1565 JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1566 LogDebug("entered");
1569 if (argumentCount != 0) {
1570 LogError("Wrong argument count");
1571 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
1580 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1581 privateObject->getContext(),
1582 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1583 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1585 TimeUtilConverter converter(context);
1587 ITZDatePtr tzDate(privateObject->getObject());
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");
1603 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1605 JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1606 LogDebug("entered");
1608 if (argumentCount != 0) {
1609 LogError("Wrong argument count");
1610 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
1619 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1620 privateObject->getContext(),
1621 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1622 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1624 TimeUtilConverter converter(context);
1626 ITZDatePtr tzDate(privateObject->getObject());
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");
1642 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1645 JSValueRef JSTZDate::getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1646 LogDebug("entered");
1649 if (argumentCount != 0) {
1650 LogError("Wrong argument count");
1651 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
1660 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1661 privateObject->getContext(),
1662 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1663 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1665 TimeUtilConverter converter(context);
1667 ITZDatePtr tzDate(privateObject->getObject());
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");
1683 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1686 JSValueRef JSTZDate::getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1687 LogDebug("entered");
1690 if (argumentCount != 0) {
1691 LogError("Wrong argument count");
1692 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
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");
1701 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1702 privateObject->getContext(),
1703 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1704 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1706 TimeUtilConverter converter(context);
1708 ITZDatePtr tzDate(privateObject->getObject());
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");
1724 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");