Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_DateTimeUtils.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
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_DateTimeUtils.cpp
20  * @brief               This is the implementation file for the _DateTimeUtils class.
21  */
22
23 #include <FBaseDateTime.h>
24 #include "FUiCtrl_DateTimeUtils.h"
25 #include "FUi_ResourceManager.h"
26
27 using namespace Tizen::Base;
28
29 namespace Tizen { namespace Ui { namespace Controls
30 {
31
32 _DateTimeUtils::~_DateTimeUtils(void)
33 {
34 }
35
36 _DateTimeUtils::_DateTimeUtils(void)
37 {
38 }
39
40 const String
41 _DateTimeUtils::GetMonthString(int month) const
42 {
43         String text;
44         text.Clear();
45         switch (month)
46         {
47         case 1:
48                 GET_STRING_CONFIG(IDS_COM_BODY_JAN, text);
49                 break;
50
51         case 2:
52                 GET_STRING_CONFIG(IDS_COM_BODY_FEB, text);
53                 break;
54
55         case 3:
56                 GET_STRING_CONFIG(IDS_COM_BODY_MAR, text);
57                 break;
58
59         case 4:
60                 GET_STRING_CONFIG(IDS_COM_BODY_APR, text);
61                 break;
62
63         case 5:
64                 GET_STRING_CONFIG(IDS_COM_BODY_MAY, text);
65                 break;
66
67         case 6:
68                 GET_STRING_CONFIG(IDS_COM_BODY_JUN, text);
69                 break;
70
71         case 7:
72                 GET_STRING_CONFIG(IDS_COM_BODY_JUL, text);
73                 break;
74
75         case 8:
76                 GET_STRING_CONFIG(IDS_COM_BODY_AUG, text);
77                 break;
78
79         case 9:
80                 GET_STRING_CONFIG(IDS_COM_BODY_SEP, text);
81                 break;
82
83         case 10:
84                 GET_STRING_CONFIG(IDS_COM_BODY_OCT, text);
85                 break;
86
87         case 11:
88                 GET_STRING_CONFIG(IDS_COM_BODY_NOV, text);
89                 break;
90
91         case 12:
92                 GET_STRING_CONFIG(IDS_COM_BODY_DEC, text);
93                 break;
94
95         default:
96                 break;
97         }
98         return text;
99 }
100
101 int
102 _DateTimeUtils::CalculateMaxDay(int displayYear, int month) const
103 {
104         int maxDay = 0;
105         switch (month)
106         {
107         case 1:
108                 // fall through
109         case 3:
110                 // fall through
111         case 5:
112                 // fall through
113         case 7:
114                 // fall through
115         case 8:
116                 // fall through
117         case 10:
118                 // fall through
119         case 12:
120                 maxDay = 31;
121                 break;
122
123         case 2:
124                 if (IsLeapYear(displayYear))
125                 {
126                         maxDay = 29;
127                 }
128                 else
129                 {
130                         maxDay = 28;
131                 }
132                 break;
133
134         default:
135                 maxDay = 30;
136                 break;
137         }
138         return maxDay;
139 }
140
141 bool
142 _DateTimeUtils::IsLeapYear(int year) const
143 {
144         return DateTime::IsLeapYear(year);
145 }
146
147 }}} // Tizen::Ui::Controls