Update change log and spec for wrt-plugins-tizen_0.4.57
[platform/framework/web/wrt-plugins-tizen.git] / src / TimeUtil / TimeUtilConverter.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18
19
20
21 #ifndef _JS_TIZEN_TIMEUTIL_CONVERTER_H_
22 #define _JS_TIZEN_TIMEUTIL_CONVERTER_H_
23
24 #include <vector>
25 #include <string>
26
27 #include <CommonsJavaScript/Converter.h>
28 #include <CommonsJavaScript/ScopedJSStringRef.h>
29
30 #include "TZDate.h"
31 #include "DurationProperties.h"
32
33 using namespace WrtDeviceApis::CommonsJavaScript;
34
35 namespace DeviceAPI {
36 namespace Time {
37
38
39 class TimeUtilConverter : public Converter
40 {
41     public:
42         using Converter::toJSValueRef;
43     public:
44         explicit TimeUtilConverter(JSContextRef context);
45         virtual  ~TimeUtilConverter();
46         short toShort(const JSValueRef& arg);
47
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         std::string getDurationUnitString(JSValueRef value);
59         std::string getDurationUnitString(JSObjectRef object);
60         short toDurationUnit(std::string strUnit);
61         std::string toDurationUnitString(short unit);
62         long long convertDurationLength(DurationProperties duration, short unit);
63         double getTimeInMilliseconds(JSValueRef arg);
64         double getTimeInMilliseconds(JSObjectRef arg);
65         tm toTZDateTime(JSValueRef arg);
66         tm toTZDateTime(JSObjectRef arg);
67         JSObjectRef toJSValueRefTZDate(const double milliseconds, const std::string &timezone);
68         DurationProperties optimizedTimeDuration(DurationProperties origin);
69 };
70
71 }
72 }
73
74 #endif /* _JS_TIZEN_TIMEUTIL_CONVERTER_H_ */