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 #ifdef IMPL_BACKWARD_COMPATIBLE
34 #include "TZDateProperties.h"
35 #endif // IMPL_BACKWARD_COMPATIBLE
37 using namespace WrtDeviceApis::CommonsJavaScript;
43 class TimeUtilConverter : public Converter {
45 using Converter::toJSValueRef;
48 explicit TimeUtilConverter(JSContextRef context);
49 virtual ~TimeUtilConverter();
50 short toShort(const JSValueRef& arg);
52 TZDateProperties getPropertiesInTZDate(JSValueRef arg);
53 TZDateProperties getPropertiesInTZDate(JSObjectRef arg);
54 JSObjectRef makeDurationObject(const DurationProperties &duration);
55 JSObjectRef makeMillisecondDurationObject(const long long length);
56 DurationPropertiesPtr getDuration(JSValueRef value);
57 DurationProperties getDurationProperties(JSValueRef value);
58 long long getDurationLength(JSValueRef value);
59 long long getDurationLength(JSObjectRef object);
60 short getDurationUnit(JSValueRef value);
61 short getDurationUnit(JSObjectRef object);
62 short toDurationUnit(std::string strUnit);
63 std::string toDurationUnitString(short unit);
64 long long convertDurationLength(DurationProperties duration, short unit);
65 double getTimeInMilliseconds(JSValueRef arg);
66 double getTimeInMilliseconds(JSObjectRef arg);
67 tm toTZDateTime(JSValueRef arg);
68 tm toTZDateTime(JSObjectRef arg);
69 JSObjectRef toJSValueRefTZDate(const double milliseconds, const std::string &timezone);
70 DurationProperties optimizedTimeDuration(DurationProperties origin);
76 #endif /* _JS_TIZEN_TIMEUTIL_CONVERTER_H_ */