Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_DateTimeModel.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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  * @file                FUiCtrl_DateTimeModel.cpp
20  * @brief               This is the implementation file for the _DateTimeModel class.
21  */
22
23 #include <FBaseResult.h>
24 #include <FBaseErrorDefine.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_DateTimeModel.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::System;
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 _DateTimeModel::~_DateTimeModel(void)
35 {
36 }
37
38 _DateTimeModel::_DateTimeModel(void)
39         : __year(1)
40         , __month(1)
41         , __day(1)
42         , __maxYear(DATETIME_YEAR_MAX)
43         , __minYear(DATETIME_YEAR_MIN)
44         , __hour(0)
45         , __minute(0)
46         , __second(0)
47 {
48         SetCurrentDateTime();
49         SetSecond(0);
50 }
51
52 void
53 _DateTimeModel::SetCurrentDateTime(void)
54 {
55         DateTime dateTime;
56         SystemTime::GetCurrentTime(WALL_TIME, dateTime);
57
58         SetYear(dateTime.GetYear());
59         SetMonth(dateTime.GetMonth());
60         SetDay(dateTime.GetDay());
61         SetHour(dateTime.GetHour());
62         SetMinute(dateTime.GetMinute());
63         SetSecond(dateTime.GetSecond());
64 }
65
66 DateTime
67 _DateTimeModel::GetDateTime(void) const
68 {
69         DateTime dateTime;
70         dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), GetSecond());
71
72         return dateTime;
73 }
74
75 void
76 _DateTimeModel::SetDateTime(const DateTime& dateTime)
77 {
78         SetYear(dateTime.GetYear());
79         SetMonth(dateTime.GetMonth());
80         SetDay(dateTime.GetDay());
81         SetHour(dateTime.GetHour());
82         SetMinute(dateTime.GetMinute());
83         SetSecond(dateTime.GetSecond());
84 }
85
86 result
87 _DateTimeModel::SetYear(int year)
88 {
89         __year = year;
90
91         return E_SUCCESS;
92 }
93
94 result
95 _DateTimeModel::SetMonth(int month)
96 {
97         __month = month;
98
99         return E_SUCCESS;
100 }
101
102 result
103 _DateTimeModel::SetDay(int day)
104 {
105         __day = day;
106
107         return E_SUCCESS;
108 }
109
110 result
111 _DateTimeModel::SetHour(int hour)
112 {
113         __hour = hour;
114
115         return E_SUCCESS;
116 }
117
118 result
119 _DateTimeModel::SetMinute(int minute)
120 {
121         __minute = minute;
122
123         return E_SUCCESS;
124 }
125
126 void
127 _DateTimeModel::SetSecond(int second)
128 {
129         if (second < DATETIME_SECOND_MIN)
130         {
131                 second = 0;
132         }
133         else if (second > DATETIME_SECOND_MAX)
134         {
135                 second = DATETIME_SECOND_MAX;
136         }
137
138         __second = second;
139 }
140
141 result
142 _DateTimeModel::SetMaxYear(int maxYear)
143 {
144         __maxYear = maxYear;
145
146         if (__maxYear < __year)
147         {
148                 __year = __maxYear;
149         }
150
151         return E_SUCCESS;
152 }
153
154 result
155 _DateTimeModel::SetMinYear(int minYear)
156 {
157         __minYear = minYear;
158
159         if (__minYear > __year)
160         {
161                 __year = __minYear;
162         }
163
164         return E_SUCCESS;
165 }
166
167 int
168 _DateTimeModel::GetYear(void) const
169 {
170         return __year;
171 }
172
173 int
174 _DateTimeModel::GetMonth(void) const
175 {
176         return __month;
177 }
178
179 int
180 _DateTimeModel::GetDay(void) const
181 {
182         return __day;
183 }
184
185 int
186 _DateTimeModel::GetHour(void) const
187 {
188         return __hour;
189 }
190
191 int
192 _DateTimeModel::GetMinute(void) const
193 {
194         return __minute;
195 }
196
197 int
198 _DateTimeModel::GetSecond(void) const
199 {
200         return __second;
201 }
202
203 result
204 _DateTimeModel::GetYearRange(int& minYear, int& maxYear) const
205 {
206         minYear = __minYear;
207         maxYear = __maxYear;
208         return E_SUCCESS;
209 }
210
211 }}} // Tizen::Ui::Controls