2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
21 #ifndef _JS_TIZEN_TIMEUTIL_CONVERTER_H_
22 #define _JS_TIZEN_TIMEUTIL_CONVERTER_H_
27 #include <CommonsJavaScript/Converter.h>
28 #include <CommonsJavaScript/ScopedJSStringRef.h>
31 #include "DurationProperties.h"
33 using namespace WrtDeviceApis::CommonsJavaScript;
39 class TimeUtilConverter : public Converter
42 using Converter::toJSValueRef;
44 explicit TimeUtilConverter(JSContextRef context);
45 virtual ~TimeUtilConverter();
46 short toShort(const JSValueRef& arg);
48 TZDateProperties getPropertiesInTZDate(JSValueRef arg);
49 TZDateProperties getPropertiesInTZDate(JSObjectRef arg);
50 JSObjectRef makeDurationObject(const DurationProperties &duration);
51 JSObjectRef makeMillisecondDurationObject(const long long length);
52 DurationPropertiesPtr getDuration(JSValueRef value);
53 DurationProperties getDurationProperties(JSValueRef value);
54 long long getDurationLength(JSValueRef value);
55 long long getDurationLength(JSObjectRef object);
56 short getDurationUnit(JSValueRef value);
57 short getDurationUnit(JSObjectRef object);
58 short toDurationUnit(std::string strUnit);
59 std::string toDurationUnitString(short unit);
60 long long convertDurationLength(DurationProperties duration, short unit);
61 double getTimeInMilliseconds(JSValueRef arg);
62 double getTimeInMilliseconds(JSObjectRef arg);
63 tm toTZDateTime(JSValueRef arg);
64 tm toTZDateTime(JSObjectRef arg);
65 JSObjectRef toJSValueRefTZDate(const double milliseconds, const std::string &timezone);
66 DurationProperties optimizedTimeDuration(DurationProperties origin);
72 #endif /* _JS_TIZEN_TIMEUTIL_CONVERTER_H_ */