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,
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 JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
342 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
346 if (argumentCount != 0) {
347 LogError("Wrong argument count");
348 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
351 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
352 if (!privateObject) {
353 LogError("Private object is not set.");
354 ThrowMsg(NullPointerException, "Private object not initialized");
357 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
358 privateObject->getContext(),
359 TIMEUTIL_FUNCTION_API_READ_FUNCS);
360 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
362 ITZDatePtr TZDate(privateObject->getObject());
363 std::string timezone = TZDate->getTimezone();
364 TimeUtilConverter converter(context);
366 return converter.toJSValueRef(timezone);
367 } Catch(NullPointerException) {
368 LogError("Exception: " << _rethrown_exception.GetMessage());
369 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
370 } Catch(UnknownException) {
371 LogError("Exception: " << _rethrown_exception.GetMessage());
372 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
373 } Catch (InvalidArgumentException) {
374 LogError("Exception: " << _rethrown_exception.GetMessage());
375 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
376 } Catch (PlatformException) {
377 LogError("Exception: " << _rethrown_exception.GetMessage());
378 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
381 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
384 JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
385 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
388 TimeUtilConverter converter(context);
391 if (argumentCount != 1) {
392 LogError("Wrong TZDate parameters count");
393 ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
396 if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
397 || !JSValueIsString(context, arguments[0])) {
398 LogError("Wrong TZDate parameters");
399 ThrowMsg(ConversionException, "Wrong TZDate parameters");
402 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
403 if (!privateObject) {
404 LogError("Private object is not set.");
405 ThrowMsg(NullPointerException, "Private object not initialized");
408 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
409 privateObject->getContext(),
410 TIMEUTIL_FUNCTION_API_READ_FUNCS);
411 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
413 std::string timezone = converter.toString(arguments[0]);
414 ITZDatePtr TZDate(privateObject->getObject());
415 return createJSObject(privateObject->getContext(), TZDate->toTimezone(timezone));
416 } Catch(NullPointerException) {
417 LogError("Exception: " << _rethrown_exception.GetMessage());
418 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
419 } Catch(UnknownException) {
420 LogError("Exception: " << _rethrown_exception.GetMessage());
421 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
422 } Catch (InvalidArgumentException) {
423 LogError("Exception: " << _rethrown_exception.GetMessage());
424 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
425 } Catch(ConversionException) {
426 LogError("Exception: " << _rethrown_exception.GetMessage());
427 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
428 } Catch (PlatformException) {
429 LogError("Exception: " << _rethrown_exception.GetMessage());
430 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
433 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
436 JSValueRef JSTZDate::diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
439 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
440 if (!privateObject) {
441 LogError("Private object is not set.");
442 ThrowMsg(NullPointerException, "Private object not initialized");
445 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
446 privateObject->getContext(),
447 TIMEUTIL_FUNCTION_API_READ_FUNCS);
449 TimeUtilConverter converter(context);
451 if (argumentCount != 1) {
452 LogError("Wrong TZDate parameters count");
453 ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
456 if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
457 || !JSValueIsObjectOfClass(context, arguments[0], getClassRef())) {
458 LogError("Wrong TZDate parameters");
459 ThrowMsg(ConversionException, "Wrong TZDate parameters");
462 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
463 ITZDatePtr TZDate(privateObject->getObject());
464 long long cmpResult = TZDate->difference(converter.getPropertiesInTZDate(arguments[0]));
470 return converter.toJSValueRef(TRUE);
472 return converter.toJSValueRef(FALSE);
477 return converter.toJSValueRef(TRUE);
479 return converter.toJSValueRef(FALSE);
484 return converter.toJSValueRef(TRUE);
486 return converter.toJSValueRef(FALSE);
490 return converter.makeMillisecondDurationObject(cmpResult);
494 JSValueRef JSTZDate::difference(JSContextRef context, JSObjectRef function,
495 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
499 return diffTZDate(context, thisObject, argumentCount, arguments, exception, DIFFERENCE);
500 } Catch(InvalidArgumentException) {
501 LogError("Exception: " << _rethrown_exception.GetMessage());
502 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
503 } Catch(NullPointerException) {
504 LogError("Exception: " << _rethrown_exception.GetMessage());
505 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
506 } Catch(UnknownException) {
507 LogError("Exception: " << _rethrown_exception.GetMessage());
508 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
509 } Catch(ConversionException) {
510 LogError("Exception: " << _rethrown_exception.GetMessage());
511 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
512 } Catch (PlatformException) {
513 LogError("Exception: " << _rethrown_exception.GetMessage());
514 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
517 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
520 JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
521 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
525 return diffTZDate(context, thisObject, argumentCount, arguments, exception, EQUALSTO);
526 } Catch(NullPointerException) {
527 LogError("Exception: " << _rethrown_exception.GetMessage());
528 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
529 } Catch(UnknownException) {
530 LogError("Exception: " << _rethrown_exception.GetMessage());
531 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
532 } Catch (InvalidArgumentException) {
533 LogError("Exception: " << _rethrown_exception.GetMessage());
534 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
535 } Catch(ConversionException) {
536 LogError("Exception: " << _rethrown_exception.GetMessage());
537 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
538 } Catch (PlatformException) {
539 LogError("Exception: " << _rethrown_exception.GetMessage());
540 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
542 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
545 JSValueRef JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
546 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
547 LogDebug("earlierThan entered");
550 return diffTZDate(context, thisObject, argumentCount, arguments, exception, EARLIERTHAN);
551 } Catch(NullPointerException) {
552 LogError("Exception: " << _rethrown_exception.GetMessage());
553 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
554 } Catch(UnknownException) {
555 LogError("Exception: " << _rethrown_exception.GetMessage());
556 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
557 } Catch (InvalidArgumentException) {
558 LogError("Exception: " << _rethrown_exception.GetMessage());
559 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
560 } Catch(ConversionException) {
561 LogError("Exception: " << _rethrown_exception.GetMessage());
562 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
563 } Catch (PlatformException) {
564 LogError("Exception: " << _rethrown_exception.GetMessage());
565 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
567 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
571 JSValueRef JSTZDate::laterThan(JSContextRef context, JSObjectRef function,
572 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
574 LogDebug("laterThan entered");
577 return diffTZDate(context, thisObject, argumentCount, arguments, exception, LATERTHAN);
578 } Catch(NullPointerException) {
579 LogError("Exception: " << _rethrown_exception.GetMessage());
580 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
581 } Catch(UnknownException) {
582 LogError("Exception: " << _rethrown_exception.GetMessage());
583 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
584 } Catch (InvalidArgumentException) {
585 LogError("Exception: " << _rethrown_exception.GetMessage());
586 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
587 } Catch(ConversionException) {
588 LogError("Exception: " << _rethrown_exception.GetMessage());
589 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
590 } Catch (PlatformException) {
591 LogError("Exception: " << _rethrown_exception.GetMessage());
592 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
594 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
598 JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
599 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
601 LogDebug("addDuration entered");
603 if (argumentCount != 1) {
604 LogError("Wrong argument count");
605 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
608 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
609 if (!privateObject) {
610 LogError("Private object is not set.");
611 ThrowMsg(NullPointerException, "Private object not initialized");
614 TimeUtilConverter converter(context);
616 DurationProperties duration = converter.getDurationPropertis(arguments[0]);
618 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
619 privateObject->getContext(),
620 TIMEUTIL_FUNCTION_API_READ_FUNCS);
621 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
623 ITZDatePtr TZDate(privateObject->getObject());
624 TZDateProperties result = TZDate->addDuration(duration);
625 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
626 } Catch(NullPointerException) {
627 LogError("Exception: " << _rethrown_exception.GetMessage());
628 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
629 } Catch(UnknownException) {
630 LogError("Exception: " << _rethrown_exception.GetMessage());
631 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
632 } Catch (InvalidArgumentException) {
633 LogError("Exception: " << _rethrown_exception.GetMessage());
634 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
635 } Catch(ConversionException) {
636 LogError("Exception: " << _rethrown_exception.GetMessage());
637 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
638 } Catch (PlatformException) {
639 LogError("Exception: " << _rethrown_exception.GetMessage());
640 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
642 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
645 JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
646 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
648 LogDebug("toUTC entered");
650 if (argumentCount != 0) {
651 LogError("Wrong argument count");
652 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
655 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
656 if (!privateObject) {
657 LogError("Private object is not set.");
658 ThrowMsg(NullPointerException, "Private object not initialized");
661 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
662 privateObject->getContext(),
663 TIMEUTIL_FUNCTION_API_READ_FUNCS);
664 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
666 ITZDatePtr TZDate(privateObject->getObject());
667 TZDateProperties result = TZDate->toUTC();
668 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
669 } Catch(NullPointerException) {
670 LogError("Exception: " << _rethrown_exception.GetMessage());
671 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
672 } Catch(UnknownException) {
673 LogError("Exception: " << _rethrown_exception.GetMessage());
674 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
675 } Catch (InvalidArgumentException) {
676 LogError("Exception: " << _rethrown_exception.GetMessage());
677 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
678 } Catch (PlatformException) {
679 LogError("Exception: " << _rethrown_exception.GetMessage());
680 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
682 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
686 JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
687 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
689 LogDebug("toLocalTimezone entered");
691 if (argumentCount != 0) {
692 LogError("Wrong argument count");
693 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
696 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
697 if (!privateObject) {
698 LogError("Private object is not set.");
699 ThrowMsg(NullPointerException, "Private object not initialized");
702 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
703 privateObject->getContext(),
704 TIMEUTIL_FUNCTION_API_READ_FUNCS);
705 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
707 ITZDatePtr TZDate(privateObject->getObject());
708 TZDateProperties result = TZDate->toLocalTimezone();
709 return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
710 } Catch(NullPointerException) {
711 LogError("Exception: " << _rethrown_exception.GetMessage());
712 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
713 } Catch(UnknownException) {
714 LogError("Exception: " << _rethrown_exception.GetMessage());
715 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
716 } Catch (InvalidArgumentException) {
717 LogError("Exception: " << _rethrown_exception.GetMessage());
718 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
719 } Catch (PlatformException) {
720 LogError("Exception: " << _rethrown_exception.GetMessage());
721 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
723 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
726 JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef function,
727 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
730 if (argumentCount != 0) {
731 LogError("Wrong argument count");
732 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
735 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
736 if (!privateObject) {
737 LogError("Private object is not set.");
738 ThrowMsg(NullPointerException, "Private object not initialized");
741 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
742 privateObject->getContext(),
743 TIMEUTIL_FUNCTION_API_READ_FUNCS);
744 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
746 TimeUtilConverter converter(context);
748 ITZDatePtr TZDate(privateObject->getObject());
749 std::string result = TZDate->toDateString(true);
750 return converter.toJSValueRef(result);
751 } Catch(NullPointerException) {
752 LogError("Exception: " << _rethrown_exception.GetMessage());
753 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
754 } Catch(UnknownException) {
755 LogError("Exception: " << _rethrown_exception.GetMessage());
756 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
757 } Catch (InvalidArgumentException) {
758 LogError("Exception: " << _rethrown_exception.GetMessage());
759 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
760 } Catch (PlatformException) {
761 LogError("Exception: " << _rethrown_exception.GetMessage());
762 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
765 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
768 JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef function,
769 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
772 if (argumentCount != 0) {
773 LogError("Wrong argument count");
774 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
777 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
778 if (!privateObject) {
779 LogError("Private object is not set.");
780 ThrowMsg(NullPointerException, "Private object not initialized");
783 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
784 privateObject->getContext(),
785 TIMEUTIL_FUNCTION_API_READ_FUNCS);
786 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
788 TimeUtilConverter converter(context);
790 ITZDatePtr TZDate(privateObject->getObject());
791 std::string result = TZDate->toTimeString(true);
792 return converter.toJSValueRef(result);
793 } Catch(NullPointerException) {
794 LogError("Exception: " << _rethrown_exception.GetMessage());
795 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
796 } Catch(UnknownException) {
797 LogError("Exception: " << _rethrown_exception.GetMessage());
798 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
799 } Catch (InvalidArgumentException) {
800 LogError("Exception: " << _rethrown_exception.GetMessage());
801 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
802 } Catch (PlatformException) {
803 LogError("Exception: " << _rethrown_exception.GetMessage());
804 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
807 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
810 JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
811 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
814 if (argumentCount != 0) {
815 LogError("Wrong argument count");
816 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
819 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
820 if (!privateObject) {
821 LogError("Private object is not set.");
822 ThrowMsg(NullPointerException, "Private object not initialized");
825 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
826 privateObject->getContext(),
827 TIMEUTIL_FUNCTION_API_READ_FUNCS);
828 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
830 TimeUtilConverter converter(context);
832 ITZDatePtr TZDate(privateObject->getObject());
833 std::string result = TZDate->toString(true);
834 return converter.toJSValueRef(result);
835 } Catch(NullPointerException) {
836 LogError("Exception: " << _rethrown_exception.GetMessage());
837 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
838 } Catch(UnknownException) {
839 LogError("Exception: " << _rethrown_exception.GetMessage());
840 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
841 } Catch (InvalidArgumentException) {
842 LogError("Exception: " << _rethrown_exception.GetMessage());
843 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
844 } Catch (PlatformException) {
845 LogError("Exception: " << _rethrown_exception.GetMessage());
846 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
849 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
852 JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
853 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
856 if (argumentCount != 0) {
857 LogError("Wrong argument count");
858 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
861 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
862 if (!privateObject) {
863 LogError("Private object is not set.");
864 ThrowMsg(NullPointerException, "Private object not initialized");
867 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
868 privateObject->getContext(),
869 TIMEUTIL_FUNCTION_API_READ_FUNCS);
870 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
872 TimeUtilConverter converter(context);
874 ITZDatePtr TZDate(privateObject->getObject());
875 std::string result = TZDate->toDateString();
876 return converter.toJSValueRef(result);
877 } Catch(NullPointerException) {
878 LogError("Exception: " << _rethrown_exception.GetMessage());
879 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
880 } Catch(UnknownException) {
881 LogError("Exception: " << _rethrown_exception.GetMessage());
882 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
883 } Catch (InvalidArgumentException) {
884 LogError("Exception: " << _rethrown_exception.GetMessage());
885 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
886 } Catch (PlatformException) {
887 LogError("Exception: " << _rethrown_exception.GetMessage());
888 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
891 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
894 JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
895 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
898 if (argumentCount != 0) {
899 LogError("Wrong argument count");
900 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
903 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
904 if (!privateObject) {
905 LogError("Private object is not set.");
906 ThrowMsg(NullPointerException, "Private object not initialized");
909 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
910 privateObject->getContext(),
911 TIMEUTIL_FUNCTION_API_READ_FUNCS);
912 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
914 TimeUtilConverter converter(context);
916 ITZDatePtr TZDate(privateObject->getObject());
917 std::string result = TZDate->toTimeString();
918 return converter.toJSValueRef(result);
919 } Catch(NullPointerException) {
920 LogError("Exception: " << _rethrown_exception.GetMessage());
921 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
922 } Catch(UnknownException) {
923 LogError("Exception: " << _rethrown_exception.GetMessage());
924 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
925 } Catch (InvalidArgumentException) {
926 LogError("Exception: " << _rethrown_exception.GetMessage());
927 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
928 } Catch (PlatformException) {
929 LogError("Exception: " << _rethrown_exception.GetMessage());
930 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
933 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
937 JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
938 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
941 if (argumentCount != 0) {
942 LogError("Wrong argument count");
943 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
946 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
947 if (!privateObject) {
948 LogError("Private object is not set.");
949 ThrowMsg(NullPointerException, "Private object not initialized");
952 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
953 privateObject->getContext(),
954 TIMEUTIL_FUNCTION_API_READ_FUNCS);
955 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
957 TimeUtilConverter converter(context);
959 ITZDatePtr TZDate(privateObject->getObject());
960 std::string result = TZDate->toString();
961 return converter.toJSValueRef(result);
962 } Catch(NullPointerException) {
963 LogError("Exception: " << _rethrown_exception.GetMessage());
964 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
965 } Catch(UnknownException) {
966 LogError("Exception: " << _rethrown_exception.GetMessage());
967 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
968 } Catch (InvalidArgumentException) {
969 LogError("Exception: " << _rethrown_exception.GetMessage());
970 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
971 } Catch (PlatformException) {
972 LogError("Exception: " << _rethrown_exception.GetMessage());
973 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
976 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
979 JSValueRef JSTZDate::getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
980 JSValueRef * exception) {
983 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
984 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
987 JSValueRef JSTZDate::getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
988 JSValueRef * exception) {
991 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DAY_OF_WEEK;
992 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
995 JSValueRef JSTZDate::getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
996 JSValueRef * exception) {
999 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
1000 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1003 JSValueRef JSTZDate::getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1004 JSValueRef * exception) {
1007 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
1008 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1011 JSValueRef JSTZDate::getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1012 JSValueRef * exception) {
1015 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
1016 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1017 } //getMilliseconds()
1019 JSValueRef JSTZDate::getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1020 JSValueRef * exception) {
1023 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
1024 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1027 JSValueRef JSTZDate::getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1028 JSValueRef * exception) {
1030 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
1031 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1034 JSValueRef JSTZDate::getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1035 JSValueRef * exception) {
1038 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
1039 return getTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1042 JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
1043 ITZDate::TZDateFields dateFields) {
1045 if (argumentCount != 0) {
1046 LogError("Wrong argument count");
1047 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1050 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1052 if (privateObject == NULL) {
1053 LogError(">>> NULL Exception");
1054 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1057 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1058 privateObject->getContext(),
1059 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1060 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1062 ITZDatePtr tzDate(privateObject->getObject());
1063 long retVal = tzDate->get(dateFields);
1065 TimeUtilConverter converter(context);
1066 LogDebug(">>> retVal:" << retVal);
1067 return converter.toJSValueRef(static_cast<int> (retVal));
1068 } Catch(NullPointerException) {
1069 LogError("Exception: " << _rethrown_exception.GetMessage());
1070 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1071 } Catch(UnknownException) {
1072 LogError("Exception: " << _rethrown_exception.GetMessage());
1073 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1074 } Catch (InvalidArgumentException) {
1075 LogError("Exception: " << _rethrown_exception.GetMessage());
1076 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1077 } Catch (PlatformException) {
1078 LogError("Exception: " << _rethrown_exception.GetMessage());
1079 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1082 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1085 JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1086 JSValueRef * exception) {
1089 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_DATE;
1092 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1093 } Catch(NullPointerException) {
1094 LogError("Exception: " << _rethrown_exception.GetMessage());
1095 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1096 } Catch(UnknownException) {
1097 LogError("Exception: " << _rethrown_exception.GetMessage());
1098 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1099 } Catch (InvalidArgumentException) {
1100 LogError("Exception: " << _rethrown_exception.GetMessage());
1101 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1102 } Catch(ConversionException) {
1103 LogError("Exception: " << _rethrown_exception.GetMessage());
1104 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1105 } Catch (PlatformException) {
1106 LogError("Exception: " << _rethrown_exception.GetMessage());
1107 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1110 return JSValueMakeNull(context);
1113 JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1114 JSValueRef * exception) {
1117 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_YEAR;
1120 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1121 } Catch(NullPointerException) {
1122 LogError("Exception: " << _rethrown_exception.GetMessage());
1123 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1124 } Catch(UnknownException) {
1125 LogError("Exception: " << _rethrown_exception.GetMessage());
1126 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1127 } Catch (InvalidArgumentException) {
1128 LogError("Exception: " << _rethrown_exception.GetMessage());
1129 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1130 } Catch(ConversionException) {
1131 LogError("Exception: " << _rethrown_exception.GetMessage());
1132 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1133 } Catch (PlatformException) {
1134 LogError("Exception: " << _rethrown_exception.GetMessage());
1135 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1138 return JSValueMakeNull(context);
1141 JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1142 JSValueRef * exception) {
1145 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_HOUR_OF_DAY;
1148 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1149 } Catch(NullPointerException) {
1150 LogError("Exception: " << _rethrown_exception.GetMessage());
1151 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1152 } Catch(UnknownException) {
1153 LogError("Exception: " << _rethrown_exception.GetMessage());
1154 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1155 } Catch (InvalidArgumentException) {
1156 LogError("Exception: " << _rethrown_exception.GetMessage());
1157 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1158 } Catch(ConversionException) {
1159 LogError("Exception: " << _rethrown_exception.GetMessage());
1160 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1161 } Catch (PlatformException) {
1162 LogError("Exception: " << _rethrown_exception.GetMessage());
1163 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1166 return JSValueMakeNull(context);
1169 JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1170 JSValueRef * exception) {
1173 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MILLISECOND;
1176 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1177 } Catch(NullPointerException) {
1178 LogError("Exception: " << _rethrown_exception.GetMessage());
1179 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1180 } Catch(UnknownException) {
1181 LogError("Exception: " << _rethrown_exception.GetMessage());
1182 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1183 } Catch (InvalidArgumentException) {
1184 LogError("Exception: " << _rethrown_exception.GetMessage());
1185 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1186 } Catch(ConversionException) {
1187 LogError("Exception: " << _rethrown_exception.GetMessage());
1188 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1189 } Catch (PlatformException) {
1190 LogError("Exception: " << _rethrown_exception.GetMessage());
1191 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1194 return JSValueMakeNull(context);
1195 } //setMilliseconds()
1197 JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1198 JSValueRef * exception) {
1201 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MINUTE;
1204 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1205 } Catch(NullPointerException) {
1206 LogError("Exception: " << _rethrown_exception.GetMessage());
1207 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1208 } Catch(UnknownException) {
1209 LogError("Exception: " << _rethrown_exception.GetMessage());
1210 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1211 } Catch (InvalidArgumentException) {
1212 LogError("Exception: " << _rethrown_exception.GetMessage());
1213 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1214 } Catch(ConversionException) {
1215 LogError("Exception: " << _rethrown_exception.GetMessage());
1216 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1217 } Catch (PlatformException) {
1218 LogError("Exception: " << _rethrown_exception.GetMessage());
1219 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1222 return JSValueMakeNull(context);
1225 JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1226 JSValueRef * exception) {
1229 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_MONTH;
1232 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1233 } Catch(NullPointerException) {
1234 LogError("Exception: " << _rethrown_exception.GetMessage());
1235 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1236 } Catch(UnknownException) {
1237 LogError("Exception: " << _rethrown_exception.GetMessage());
1238 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1239 } Catch (InvalidArgumentException) {
1240 LogError("Exception: " << _rethrown_exception.GetMessage());
1241 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1242 } Catch(ConversionException) {
1243 LogError("Exception: " << _rethrown_exception.GetMessage());
1244 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1245 } Catch (PlatformException) {
1246 LogError("Exception: " << _rethrown_exception.GetMessage());
1247 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1250 return JSValueMakeNull(context);
1253 JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1254 JSValueRef * exception) {
1257 ITZDate::TZDateFields dateFields = ITZDate::TZDATE_SECOND;
1260 setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
1261 } Catch(NullPointerException) {
1262 LogError("Exception: " << _rethrown_exception.GetMessage());
1263 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1264 } Catch(UnknownException) {
1265 LogError("Exception: " << _rethrown_exception.GetMessage());
1266 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1267 } Catch (InvalidArgumentException) {
1268 LogError("Exception: " << _rethrown_exception.GetMessage());
1269 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1270 } Catch(ConversionException) {
1271 LogError("Exception: " << _rethrown_exception.GetMessage());
1272 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1273 } Catch (PlatformException) {
1274 LogError("Exception: " << _rethrown_exception.GetMessage());
1275 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1278 return JSValueMakeNull(context);
1282 JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
1283 JSValueRef * exception, ITZDate::TZDateFields dateFields) {
1285 if (argumentCount != 1) {
1286 LogError("Wrong parameters");
1287 ThrowMsg(InvalidArgumentException, "argumentIndex is bigger than argumentCount");
1290 TimeUtilConverter converter(context);
1292 if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
1293 || (!JSValueIsNumber(context, arguments[0])))
1294 ThrowMsg(ConversionException, "Invalid Argument");
1296 int data = converter.toInt(arguments[0]);
1298 if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
1299 ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1301 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
1303 if (privateObject == NULL) {
1304 LogError(">>> NULL Exception");
1305 ThrowMsg(UnknownException, "privateObject is NULL");
1308 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1309 privateObject->getContext(),
1310 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1311 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1313 ITZDatePtr tzDate(privateObject->getObject());
1314 tzDate->set(dateFields, static_cast<long> (data));
1316 return JSValueMakeNull(context);
1319 JSValueRef JSTZDate::getUTCDate(JSContextRef context, JSObjectRef function,
1320 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1321 LogDebug("Entered");
1322 return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_DATE, exception);
1325 JSValueRef JSTZDate::getUTCDay(JSContextRef context, JSObjectRef function,
1326 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1327 LogDebug("Entered");
1328 return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_DAY_OF_WEEK, exception);
1331 JSValueRef JSTZDate::getUTCFullYear(JSContextRef context, JSObjectRef function,
1332 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1333 LogDebug("Entered");
1334 return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_YEAR, exception);
1337 JSValueRef JSTZDate::getUTCHours(JSContextRef context, JSObjectRef function,
1338 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1339 LogDebug("Entered");
1340 return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_HOUR_OF_DAY, exception);
1343 JSValueRef JSTZDate::getUTCMilliseconds(JSContextRef context, JSObjectRef function,
1344 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1345 LogDebug("Entered");
1346 return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MILLISECOND, exception);
1349 JSValueRef JSTZDate::getUTCMinutes(JSContextRef context, JSObjectRef function,
1350 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1351 LogDebug("Entered");
1352 return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MINUTE, exception);
1355 JSValueRef JSTZDate::getUTCMonth(JSContextRef context, JSObjectRef function,
1356 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1357 LogDebug("Entered");
1358 return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_MONTH, exception);
1361 JSValueRef JSTZDate::getUTCSeconds(JSContextRef context, JSObjectRef function,
1362 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1363 LogDebug("Entered");
1364 return getUTCTZDateValue(context, thisObject, argumentCount, ITZDate::TZDATE_SECOND, exception);
1367 JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, ITZDate::TZDateFields DateFields, JSValueRef * exception) {
1368 LogDebug("Entered");
1370 if (argumentCount != 0) {
1371 LogError("Wrong argument count");
1372 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1375 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1376 if (!privateObject) {
1377 LogError("Private object is not set.");
1378 ThrowMsg(NullPointerException, "Private object not initialized");
1381 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1382 privateObject->getContext(),
1383 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1384 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1386 TimeUtilConverter converter(context);
1388 ITZDatePtr TZDate(privateObject->getObject());
1389 long result = TZDate->getUTC(DateFields);
1391 return converter.toJSValueRefLong(result);
1392 } Catch(NullPointerException) {
1393 LogError("Exception: " << _rethrown_exception.GetMessage());
1394 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1395 } Catch(UnknownException) {
1396 LogError("Exception: " << _rethrown_exception.GetMessage());
1397 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1398 } Catch (InvalidArgumentException) {
1399 LogError("Exception: " << _rethrown_exception.GetMessage());
1400 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1401 } Catch (PlatformException) {
1402 LogError("Exception: " << _rethrown_exception.GetMessage());
1403 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1406 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1409 JSValueRef JSTZDate::setUTCDate(JSContextRef context, JSObjectRef function,
1410 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1411 LogDebug("Entered");
1413 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_DATE, exception);
1416 JSValueRef JSTZDate::setUTCFullYear(JSContextRef context, JSObjectRef function,
1417 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1418 LogDebug("Entered");
1420 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_YEAR, exception);
1423 JSValueRef JSTZDate::setUTCHours(JSContextRef context, JSObjectRef function,
1424 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1425 LogDebug("Entered");
1427 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_HOUR_OF_DAY, exception);
1430 JSValueRef JSTZDate::setUTCMilliseconds(JSContextRef context, JSObjectRef function,
1431 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1432 LogDebug("Entered");
1434 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MILLISECOND, exception);
1437 JSValueRef JSTZDate::setUTCMinutes(JSContextRef context, JSObjectRef function,
1438 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1439 LogDebug("Entered");
1441 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MINUTE, exception);
1444 JSValueRef JSTZDate::setUTCMonth(JSContextRef context, JSObjectRef function,
1445 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1446 LogDebug("Entered");
1448 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_MONTH, exception);
1451 JSValueRef JSTZDate::setUTCSeconds(JSContextRef context, JSObjectRef function,
1452 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1453 LogDebug("Entered");
1455 return setUTCTZDateValue(context, thisObject, argumentCount, arguments, ITZDate::TZDATE_SECOND, exception);
1458 JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject,
1459 size_t argumentCount, const JSValueRef arguments[], ITZDate::TZDateFields dateFields, JSValueRef * exception) {
1460 LogDebug("Entered");
1462 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1463 if (!privateObject) {
1464 LogError("Private object is not set.");
1465 ThrowMsg(NullPointerException, "Private object not initialized");
1468 if (argumentCount != 1) {
1469 LogError("Wrong TZDate parameters count");
1470 ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
1473 if (!JSValueIsNumber(context, arguments[0]))
1475 LogError("Wrong TZDate parameters");
1476 ThrowMsg(ConversionException, "Wrong TZDate parameters");
1479 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1480 privateObject->getContext(),
1481 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1482 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1484 TimeUtilConverter converter(context);
1486 long data = converter.FromJSValueReftolong(arguments[0]);
1488 if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
1489 ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
1491 ITZDatePtr TZDate(privateObject->getObject());
1492 TZDate->setUTC(dateFields, data);
1494 return JSValueMakeNull(context);
1495 } Catch(NullPointerException) {
1496 LogError("Exception: " << _rethrown_exception.GetMessage());
1497 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1498 } Catch(UnknownException) {
1499 LogError("Exception: " << _rethrown_exception.GetMessage());
1500 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1501 } Catch (InvalidArgumentException) {
1502 LogError("Exception: " << _rethrown_exception.GetMessage());
1503 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1504 } Catch(ConversionException) {
1505 LogError("Exception: " << _rethrown_exception.GetMessage());
1506 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
1507 } Catch (PlatformException) {
1508 LogError("Exception: " << _rethrown_exception.GetMessage());
1509 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1512 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1515 JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1516 LogDebug("entered");
1518 if (argumentCount != 0) {
1519 LogError("Wrong argument count");
1520 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1523 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1524 if (!privateObject) {
1525 LogError("Private object is not set.");
1526 ThrowMsg(NullPointerException, "Private object not initialized");
1529 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1530 privateObject->getContext(),
1531 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1532 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1534 TimeUtilConverter converter(context);
1536 ITZDatePtr tzDate(privateObject->getObject());
1540 return converter.toJSValueRef(tzDate->getTimezoneAbbreviation());
1541 } Catch(NullPointerException) {
1542 LogError("Exception: " << _rethrown_exception.GetMessage());
1543 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1544 } Catch(UnknownException) {
1545 LogError("Exception: " << _rethrown_exception.GetMessage());
1546 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1547 } Catch (InvalidArgumentException) {
1548 LogError("Exception: " << _rethrown_exception.GetMessage());
1549 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1550 } Catch (PlatformException) {
1551 LogError("Exception: " << _rethrown_exception.GetMessage());
1552 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1554 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1557 JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1558 LogDebug("entered");
1561 if (argumentCount != 0) {
1562 LogError("Wrong argument count");
1563 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1566 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1567 if (!privateObject) {
1568 LogError("Private object is not set.");
1569 ThrowMsg(NullPointerException, "Private object not initialized");
1572 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1573 privateObject->getContext(),
1574 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1575 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1577 TimeUtilConverter converter(context);
1579 ITZDatePtr tzDate(privateObject->getObject());
1581 return converter.toJSValueRefLong(tzDate->secondsFromUTC());
1582 } Catch(NullPointerException) {
1583 LogError("Exception: " << _rethrown_exception.GetMessage());
1584 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1585 } Catch(UnknownException) {
1586 LogError("Exception: " << _rethrown_exception.GetMessage());
1587 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1588 } Catch (InvalidArgumentException) {
1589 LogError("Exception: " << _rethrown_exception.GetMessage());
1590 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1591 } Catch (PlatformException) {
1592 LogError("Exception: " << _rethrown_exception.GetMessage());
1593 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1595 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1597 JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1598 LogDebug("entered");
1600 if (argumentCount != 0) {
1601 LogError("Wrong argument count");
1602 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1605 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1606 if (!privateObject) {
1607 LogError("Private object is not set.");
1608 ThrowMsg(NullPointerException, "Private object not initialized");
1611 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1612 privateObject->getContext(),
1613 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1614 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1616 TimeUtilConverter converter(context);
1618 ITZDatePtr tzDate(privateObject->getObject());
1620 return converter.toJSValueRef(tzDate->isDST());
1621 } Catch(NullPointerException) {
1622 LogError("Exception: " << _rethrown_exception.GetMessage());
1623 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1624 } Catch(UnknownException) {
1625 LogError("Exception: " << _rethrown_exception.GetMessage());
1626 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1627 } Catch (InvalidArgumentException) {
1628 LogError("Exception: " << _rethrown_exception.GetMessage());
1629 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1630 } Catch (PlatformException) {
1631 LogError("Exception: " << _rethrown_exception.GetMessage());
1632 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1634 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1637 JSValueRef JSTZDate::getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1638 LogDebug("entered");
1641 if (argumentCount != 0) {
1642 LogError("Wrong argument count");
1643 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1646 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1647 if (!privateObject) {
1648 LogError("Private object is not set.");
1649 ThrowMsg(NullPointerException, "Private object not initialized");
1652 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1653 privateObject->getContext(),
1654 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1655 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1657 TimeUtilConverter converter(context);
1659 ITZDatePtr tzDate(privateObject->getObject());
1661 return createJSObject(privateObject->getContext(), tzDate->getDSTTransition(ITZDate::PREV_TRANSITION));
1662 } Catch(NullPointerException) {
1663 LogError("Exception: " << _rethrown_exception.GetMessage());
1664 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1665 } Catch(UnknownException) {
1666 LogError("Exception: " << _rethrown_exception.GetMessage());
1667 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1668 } Catch (InvalidArgumentException) {
1669 LogError("Exception: " << _rethrown_exception.GetMessage());
1670 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1671 } Catch (PlatformException) {
1672 LogError("Exception: " << _rethrown_exception.GetMessage());
1673 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1675 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1678 JSValueRef JSTZDate::getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
1679 LogDebug("entered");
1682 if (argumentCount != 0) {
1683 LogError("Wrong argument count");
1684 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1687 TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
1688 if (!privateObject) {
1689 LogError("Private object is not set.");
1690 ThrowMsg(NullPointerException, "Private object not initialized");
1693 AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
1694 privateObject->getContext(),
1695 TIMEUTIL_FUNCTION_API_READ_FUNCS);
1696 TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
1698 TimeUtilConverter converter(context);
1700 ITZDatePtr tzDate(privateObject->getObject());
1702 return createJSObject(privateObject->getContext(), tzDate->getDSTTransition(ITZDate::NEXT_TRANSITION));
1703 } Catch(NullPointerException) {
1704 LogError("Exception: " << _rethrown_exception.GetMessage());
1705 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1706 } Catch(UnknownException) {
1707 LogError("Exception: " << _rethrown_exception.GetMessage());
1708 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1709 } Catch (InvalidArgumentException) {
1710 LogError("Exception: " << _rethrown_exception.GetMessage());
1711 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
1712 } Catch (PlatformException) {
1713 LogError("Exception: " << _rethrown_exception.GetMessage());
1714 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
1716 return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");