2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
19 * @file FUiCtrl_DateTimeModel.cpp
20 * @brief This is the implementation file for the _DateTimeModel class.
23 #include <FBaseResult.h>
24 #include <FBaseErrorDefine.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_DateTimeModel.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::System;
31 namespace Tizen { namespace Ui { namespace Controls
34 _DateTimeModel::~_DateTimeModel(void)
38 _DateTimeModel::_DateTimeModel(void)
42 , __maxYear(DATETIME_YEAR_MAX)
43 , __minYear(DATETIME_YEAR_MIN)
53 _DateTimeModel::SetCurrentDateTime(void)
56 SystemTime::GetCurrentTime(WALL_TIME, dateTime);
58 SetYear(dateTime.GetYear());
59 SetMonth(dateTime.GetMonth());
60 SetDay(dateTime.GetDay());
61 SetHour(dateTime.GetHour());
62 SetMinute(dateTime.GetMinute());
63 SetSecond(dateTime.GetSecond());
67 _DateTimeModel::GetDateTime(void) const
70 dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), GetSecond());
76 _DateTimeModel::SetDateTime(const DateTime& dateTime)
78 SetYear(dateTime.GetYear());
79 SetMonth(dateTime.GetMonth());
80 SetDay(dateTime.GetDay());
81 SetHour(dateTime.GetHour());
82 SetMinute(dateTime.GetMinute());
83 SetSecond(dateTime.GetSecond());
87 _DateTimeModel::SetYear(int year)
95 _DateTimeModel::SetMonth(int month)
103 _DateTimeModel::SetDay(int day)
111 _DateTimeModel::SetHour(int hour)
119 _DateTimeModel::SetMinute(int minute)
127 _DateTimeModel::SetSecond(int second)
129 if (second < DATETIME_SECOND_MIN)
133 else if (second > DATETIME_SECOND_MAX)
135 second = DATETIME_SECOND_MAX;
142 _DateTimeModel::SetMaxYear(int maxYear)
146 if (__maxYear < __year)
155 _DateTimeModel::SetMinYear(int minYear)
159 if (__minYear > __year)
168 _DateTimeModel::GetYear(void) const
174 _DateTimeModel::GetMonth(void) const
180 _DateTimeModel::GetDay(void) const
186 _DateTimeModel::GetHour(void) const
192 _DateTimeModel::GetMinute(void) const
198 _DateTimeModel::GetSecond(void) const
204 _DateTimeModel::GetYearRange(int& minYear, int& maxYear) const
211 }}} // Tizen::Ui::Controls