diff options
Diffstat (limited to 'mobile_src/TimeUtil/JSTZDate.h')
-rwxr-xr-x | mobile_src/TimeUtil/JSTZDate.h | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/mobile_src/TimeUtil/JSTZDate.h b/mobile_src/TimeUtil/JSTZDate.h new file mode 100755 index 0000000..b8e5065 --- /dev/null +++ b/mobile_src/TimeUtil/JSTZDate.h @@ -0,0 +1,224 @@ +// +// Tizen Web Device API +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + + + +#ifndef _JS_TIZEN_TZDATE_H_ +#define _JS_TIZEN_TZDATE_H_ + +#include <JavaScriptCore/JavaScript.h> +#include <CommonsJavaScript/PrivateObject.h> +#include "TZDate.h" + +namespace DeviceAPI { +namespace Time { + +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TZDatePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> TZDatePrivObject; + +class JSTZDate +{ +public: + + static const JSClassDefinition* getClassInfo(); + + static const JSClassRef getClassRef(); + static JSObjectRef createJSObject(JSContextRef context, TZDatePtr tzDate); + static JSObjectRef createJSObject(JSContextRef context, const bool isNotNull = true); + static JSObjectRef createJSObject(JSContextRef context, const std::string &timezone); + static JSObjectRef createJSObject(JSContextRef context, const double milliseconds, const std::string &timezone); + static JSObjectRef createJSObject(JSContextRef context, const TZDateProperties &properties); + static JSObjectRef 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); + static JSObjectRef createJSObject(JSContextRef context, const std::string &dateString, const double milliseconds, const std::string &timezone); + + + static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +private: + enum CompareType { + DIFFERENCE, + EQUALSTO, + EARLIERTHAN, + LATERTHAN + }; + /** + * This member variable contains the values which has to be passed when + * the this class is embedded into JS Engine. + */ + static JSClassDefinition m_classInfo; + + /** + * This structure describes a statically declared function property. + */ + static JSStaticFunction m_function[]; + + /** + * This member variable contains the initialization values for the + * properties of this class. The values are given according to the + * data structure JSPropertySpec. + */ + + static JSClassRef m_jsClassRef; + + /** + * The callback invoked when an object is first created. + */ + static void initialize(JSContextRef context, JSObjectRef object); + + /** + * The callback invoked when an object is finalized. + */ + static void finalize(JSObjectRef object); + + static JSValueRef getTimezone(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef toTimezone(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + + static JSValueRef diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type); + + static JSValueRef difference(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef equalsTo(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef earlierThan(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef laterThan(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef addDuration(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef toUTC(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef toLocalTimezone(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + + static JSValueRef toLocaleDateString(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef toLocaleTimeString(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef toLocaleString(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef toDateString(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef toTimeString(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef toString(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + + static JSValueRef getDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef getDay(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef getFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef getHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef getMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef getMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef getMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef getSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, + TZDate::TZDateFields dateFields); + + static JSValueRef getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, + TZDate::TZDateFields dateFields); + + static JSValueRef setDate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef setFullYear(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef setHours(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef setMilliseconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef setMinutes(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef setMonth(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef setSeconds(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], + JSValueRef * exception); + + static JSValueRef getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, + TZDate::TZDateFields DateFields, JSValueRef * exception); + static JSValueRef getUTCDate(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getUTCDay(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getUTCFullYear(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getUTCHours(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getUTCMilliseconds(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getUTCMinutes(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getUTCMonth(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getUTCSeconds(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + + static JSValueRef setUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, + const JSValueRef arguments[], TZDate::TZDateFields dateFields, JSValueRef * exception); + static JSValueRef setUTCDate(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef setUTCFullYear(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef setUTCHours(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef setUTCMilliseconds(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef setUTCMinutes(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef setUTCMonth(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef setUTCSeconds(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + + static JSValueRef getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, + size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef secondsFromUTC(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, + size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, + size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getPreviousDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, + size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); + static JSValueRef getNextDSTTransition(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, + size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception); +}; + +} +} + +#endif /* _JS_TIZEN_DATETIME_H_ */ |