sync with tizen_2.0
[platform/framework/native/appfw.git] / src / locales / FLcl_CalendarImpl.cpp
1 //
2 // Open Service Platform
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  * @file     FLcl_CalendarImpl.cpp
20  * @brief    This is the implementation file for _CalendarImpl class.
21  */
22
23 #include <new>
24 #include <unique_ptr.h>
25
26 #include <FBaseDateTime.h>
27 #include <FBaseSysLog.h>
28 #include <FApp_AppInfo.h>
29 #include <FLclGregorianCalendar.h>
30
31 #include "FLcl_CalendarImpl.h"
32 #include "FLcl_IcuCalendarImpl.h"
33 #include "FLcl_LocaleData.h"
34
35 using namespace Tizen::Base;
36
37 namespace Tizen { namespace Locales
38 {
39
40 static const int ONE_MINUTE_IN_MILLISEC = 60000;
41
42 _CalendarImpl::_CalendarImpl()
43         : __type(CALENDAR_GREGORIAN)
44         , __locale(LANGUAGE_INVALID, COUNTRY_INVALID)
45         , __timezone()
46         , __pCalendar(null)
47 {
48 }
49
50 _CalendarImpl::~_CalendarImpl()
51 {
52         delete __pCalendar;
53         __pCalendar = null;
54 }
55
56
57 Calendar*
58 _CalendarImpl::CreateCalendarInstanceN(CalendarType calendarType)
59 {
60         return CreateInstanceN(TimeZone::GetGmtTimeZone(), calendarType);
61 }
62
63 Calendar*
64 _CalendarImpl::CreateCalendarInstanceN(const TimeZone& timeZone, CalendarType calendarType)
65 {
66         return CreateInstanceN(timeZone, _LocaleData::GetOspSystemLocale(), calendarType);
67 }
68
69 Calendar*
70 _CalendarImpl::CreateCalendarInstanceN(const Locale& locale, CalendarType calendarType)
71 {
72         // Create calendar using system time zone and given locale and calendar type
73         return CreateInstanceN(TimeZone::GetGmtTimeZone(), locale, calendarType);
74 }
75
76 Calendar*
77 _CalendarImpl::CreateCalendarInstanceN(const TimeZone& timeZone, const Locale& locale, CalendarType calendarType)
78 {
79         ClearLastResult();
80         result r = E_SYSTEM;
81         switch (calendarType)
82         {
83         case CALENDAR_GREGORIAN:
84         {
85                 std::unique_ptr< GregorianCalendar > pGregCalendar(new (std::nothrow) GregorianCalendar);
86                 SysTryReturn(NID_LCL, pGregCalendar != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
87
88                 r = pGregCalendar->Construct(timeZone, locale);
89                 SysTryReturn(NID_LCL, !IsFailed(r), null, r, "[%s] Unable to construct calendar", GetErrorMessage(r));
90
91                 return pGregCalendar.release();
92         }
93
94         default:
95                 break;
96         }
97
98         std::unique_ptr< _CalendarImpl > pCalendar(new (std::nothrow) _CalendarImpl);
99         SysTryReturn(NID_LCL, pCalendar != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
100
101         r = pCalendar->Construct(timeZone, locale, calendarType);
102         SetLastResult(r);
103         SysTryReturn(NID_LCL, !IsFailed(r), null, r, "[%s] Unable to construct calendar", GetErrorMessage(r));
104         return pCalendar.release();
105 }
106
107 Calendar*
108 _CalendarImpl::CloneN(void) const
109 {
110         std::unique_ptr< _CalendarImpl > pCalendar(new (std::nothrow) _CalendarImpl());
111         SysTryReturn(NID_LCL, pCalendar != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
112
113         if (__pCalendar != null)
114         {
115                 pCalendar->__pCalendar = __pCalendar->CloneN();
116                 if (pCalendar->__pCalendar != null)
117                 {
118                         pCalendar->__type = __type;
119                         pCalendar->__locale = __locale;
120                         pCalendar->__timezone = __timezone;
121
122                         pCalendar->_pCalendarImpl = pCalendar.get();
123                 }
124         }
125
126         return pCalendar.release();
127 }
128
129 result
130 _CalendarImpl::Construct(CalendarType calendarType)
131 {
132         Locale defaultLocale = _LocaleData::GetOspSystemLocale();
133         return Construct( TimeZone::GetGmtTimeZone(), defaultLocale, calendarType);
134 }
135
136 result
137 _CalendarImpl::Construct(const TimeZone& timezone, CalendarType calendarType)
138 {
139         Locale defaultLocale = _LocaleData::GetOspSystemLocale();
140         return Construct(timezone, defaultLocale, calendarType);
141 }
142
143 result
144 _CalendarImpl::Construct(const Locale& locale, CalendarType calendarType)
145 {
146         TimeZone defaultTimeZone = TimeZone::GetGmtTimeZone();
147         return Construct(defaultTimeZone, locale, calendarType);
148 }
149
150 result
151 _CalendarImpl::Construct(const TimeZone& timeZone, const Locale& locale, CalendarType calendarType)
152 {
153         // Object is not allowed to construct twice
154         SysAssertf(__pCalendar == null,
155                            "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
156
157         SysTryReturnResult(NID_LCL, locale.GetLanguageCode() != LANGUAGE_INVALID,
158                         E_INVALID_ARG, "Invalid argument is used. Language code is invalid. Given locale is not supported");
159
160         SysTryReturnResult(NID_LCL, locale.GetCountryCode() != COUNTRY_INVALID,
161                         E_INVALID_ARG, "Invalid argument is used. Country code is invalid. Given locale is not supported");
162
163         std::unique_ptr< _IcuCalendarImpl > pCalendar(new (std::nothrow) _IcuCalendarImpl);
164         SysTryReturnResult(NID_LCL, pCalendar != null, E_OUT_OF_MEMORY, "Memory allocation failed");
165
166         result r = pCalendar->Construct(timeZone, locale, calendarType);
167         if (!IsFailed(r))
168         {
169                 __pCalendar = pCalendar.release();
170                 __type = calendarType;
171                 __locale = locale;
172                 __timezone = timeZone;
173
174                 _pCalendarImpl = this;
175                 return E_SUCCESS;
176         }
177
178         return E_SYSTEM;
179 }
180
181 result
182 _CalendarImpl::Construct(const Calendar& otherCalendar)
183 {
184         // Object is not allowed to construct twice
185         SysAssertf(__pCalendar == null,
186                            "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
187
188         result r = E_SYSTEM;
189         const _CalendarImpl* pOtherCalendar = dynamic_cast< const _CalendarImpl* >(&otherCalendar);
190         if ((pOtherCalendar != null) && (pOtherCalendar->__pCalendar != null))
191         {
192                 delete __pCalendar;
193
194                 __pCalendar = pOtherCalendar->__pCalendar->CloneN();
195                 if (__pCalendar != null)
196                 {
197                         __type = pOtherCalendar->__type;
198                         __locale = pOtherCalendar->__locale;
199                         __timezone = pOtherCalendar->__timezone;
200
201                         _pCalendarImpl = pOtherCalendar->_pCalendarImpl;
202                         return E_SUCCESS;
203                 }
204                 r = GetLastResult();
205         }
206         return r;
207 }
208
209 result
210 _CalendarImpl::SetTimeFieldImpl(TimeField field, int value)
211 {
212         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
213         SysTryReturnResult(NID_LCL, ValidateTimeField(field),
214                         E_INVALID_ARG, "Invalid argument is used. Timefield is less than 0 or grater than time field count.");
215         SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(field, value), E_OUT_OF_RANGE, "value(%d) is out of range.", value);
216
217         return __pCalendar->SetTimeField(field, value);
218 }
219
220 result
221 _CalendarImpl::SetTimeInMillisecImpl(long long millisec)
222 {
223         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
224         return __pCalendar->SetTimeInMillisec(millisec - __timezone.GetRawOffset() * ONE_MINUTE_IN_MILLISEC);
225 }
226
227 result
228 _CalendarImpl::SetTimeImpl(const DateTime& dateTime)
229 {
230         return SetTimeImpl(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
231 }
232
233 result
234 _CalendarImpl::SetTimeImpl(int year, int month, int day, int hour, int minute, int second)
235 {
236         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
237         SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_YEAR, year), E_OUT_OF_RANGE, "year(%d) is out of range.", year);
238         SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_MONTH, month), E_OUT_OF_RANGE, "month(%d) is out of range.", month);
239         SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_DAY_OF_MONTH, day), E_OUT_OF_RANGE, "day(%d) is out of range.", day);
240         SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_HOUR_OF_DAY, hour),E_OUT_OF_RANGE, "hour(%d) is out of range.", hour);
241         SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_MINUTE, minute), E_OUT_OF_RANGE, "minute(%d) is out of range.", minute);
242         SysTryReturnResult(NID_LCL, ValidateTimeFieldValue(TIME_FIELD_SECOND, second), E_OUT_OF_RANGE, "second(%d) is out of range.", second);
243
244         return __pCalendar->SetTime(year, month, day, hour, minute, second);
245 }
246
247 result
248 _CalendarImpl::SetFirstDayOfWeekImpl(DayOfWeek dayOfWeek)
249 {
250         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
251         SysTryReturnResult(NID_LCL, ValidateDaysOfWeek(dayOfWeek), E_INVALID_ARG, "Invalid argument is used. Unknown day of week");
252
253         return __pCalendar->SetFirstDayOfWeek(dayOfWeek);
254 }
255
256 result
257 _CalendarImpl::SetLenientImpl(bool lenient)
258 {
259         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
260         return __pCalendar->SetLenient(lenient);
261 }
262
263 result
264 _CalendarImpl::SetMinDaysInFirstWeekImpl(short value)
265 {
266         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
267         return __pCalendar->SetMinDaysInFirstWeek(value);
268 }
269
270 result
271 _CalendarImpl::SetTimeZoneImpl(const TimeZone& timeZone)
272 {
273         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
274
275         _timeZone = timeZone;
276         __timezone = timeZone;
277         return __pCalendar->SetTimeZone(__timezone);
278 }
279
280 result
281 _CalendarImpl::ClearImpl(void)
282 {
283         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
284         return __pCalendar->Clear();
285 }
286
287 result
288 _CalendarImpl::ClearImpl(TimeField field)
289 {
290         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
291         SysTryReturnResult(NID_LCL, ValidateTimeField(field), E_INVALID_ARG,
292                                 "Invalid argument is used. Timefield is less than 0 or grater than time field count.");
293
294         return __pCalendar->Clear(field);
295 }
296
297 result
298 _CalendarImpl::AddTimeField(TimeField field, int amount)
299 {
300         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
301
302         result r = E_INVALID_ARG;
303
304         if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
305         {
306                 r = E_INVALID_STATE;
307         }
308
309         SysTryReturnResult(NID_LCL, ValidateTimeField(field), r,
310                                 "Invalid argument is used. Timefield is less than 0 or grater than time field count.");
311
312         return __pCalendar->AddTimeField(field, amount);
313 }
314
315 result
316 _CalendarImpl::Roll(TimeField field, int amount)
317 {
318         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
319
320         result r = E_INVALID_ARG;
321         if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
322         {
323                 r = E_INVALID_STATE;
324         }
325
326         SysTryReturnResult(NID_LCL, ValidateTimeField(field), r,
327                                 "Invalid argument is used. Timefield is less than 0 or grater than time field count.");
328
329         return __pCalendar->Roll(field, amount);
330 }
331
332 result
333 _CalendarImpl::After(const _CalendarImpl& otherInstance, bool& after)
334 {
335         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
336
337         result r = E_INVALID_ARG;
338         if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
339         {
340                 r = E_INVALID_STATE;
341         }
342
343         SysTryReturnResult(NID_LCL, otherInstance.__pCalendar, r, "Invalid argument is used. otherCalendar instance is invalid");
344
345         return __pCalendar->After(*(otherInstance.__pCalendar), after);
346 }
347
348 result
349 _CalendarImpl::Before(const _CalendarImpl& otherInstance, bool& before)
350 {
351         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
352
353         result r = E_INVALID_ARG;
354         if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
355         {
356                 r = E_INVALID_STATE;
357         }
358
359         SysTryReturnResult(NID_LCL, otherInstance.__pCalendar, r, "Invalid argument is used. otherCalendar instance is invalid");
360
361         return __pCalendar->Before(*(otherInstance.__pCalendar), before);
362 }
363
364 bool
365 _CalendarImpl::Equals(const _CalendarImpl& otherInstance) const
366 {
367         if ((__pCalendar != null) && (otherInstance.__pCalendar != null))
368         {
369                 return __pCalendar->Equals(*(otherInstance.__pCalendar));
370         }
371         return (__pCalendar == otherInstance.__pCalendar);
372 }
373
374 int
375 _CalendarImpl::GetHashCode(void) const
376 {
377         Integer intValues = IsLenient() + GetFirstDayOfWeek() + GetMinDaysInFirstWeek();
378         int hashCode = intValues.GetHashCode();
379
380         long long myTicks = 0;
381         GetTimeInMillisec(myTicks);
382         hashCode = (hashCode << 5) - hashCode + LongLong(myTicks).GetHashCode()+__timezone.GetHashCode();
383
384         return hashCode;
385 }
386
387 CalendarType
388 _CalendarImpl::GetType(void) const
389 {
390         return __type;
391 }
392
393 int
394 _CalendarImpl::GetTimeFieldImpl(TimeField field) const
395 {
396         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
397         SysTryReturn(NID_LCL, ValidateTimeField(field), -1, E_INVALID_ARG,
398                                 "[%s] Invalid argument is used. Timefield is less than 0 or grater than time field count.", GetErrorMessage(E_INVALID_ARG));
399
400         return __pCalendar->GetTimeField(field);
401 }
402
403 result
404 _CalendarImpl::GetTimeInMillisecImpl(long long& millisec) const
405 {
406         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
407         result r;
408         long long tempMillisec;
409
410         r =  __pCalendar->GetTimeInMillisec(tempMillisec);
411         SysTryReturnResult(NID_LCL, r == E_SUCCESS, r, "Unable to get time in milli sec");
412         millisec = tempMillisec + __timezone.GetRawOffset() * ONE_MINUTE_IN_MILLISEC;
413         return r;
414 }
415
416 DateTime
417 _CalendarImpl::GetTimeImpl(void) const
418 {
419         int year = __pCalendar->GetTimeField(TIME_FIELD_YEAR);
420         int month = __pCalendar->GetTimeField(TIME_FIELD_MONTH);
421         int date = __pCalendar->GetTimeField(TIME_FIELD_DAY_OF_MONTH);
422
423         int hour = __pCalendar->GetTimeField(TIME_FIELD_HOUR_OF_DAY);
424         int minute = __pCalendar->GetTimeField(TIME_FIELD_MINUTE);
425         int second = __pCalendar->GetTimeField(TIME_FIELD_SECOND);
426
427         DateTime dateTime;
428         result r = dateTime.SetValue(year, month, date, hour, minute, second);
429         SysTryReturn(NID_LCL, r == E_SUCCESS, DateTime(), r, "[%s] Unable to set time in DateTime object", GetErrorMessage(r));
430
431         return dateTime;
432 }
433
434 int
435 _CalendarImpl::GetMinTimeField(TimeField field) const
436 {
437         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
438         SysTryReturn(NID_LCL, ValidateTimeField(field), -1, E_INVALID_ARG,
439                                 "[%s] Invalid argument is used. Timefield is less than 0 or grater than time field count.", GetErrorMessage(E_INVALID_ARG));
440
441         return __pCalendar->GetMinTimeField(field);
442 }
443
444 int
445 _CalendarImpl::GetActualMinTimeField(TimeField field) const
446 {
447         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
448         SysTryReturn(NID_LCL, ValidateTimeField(field), -1, E_INVALID_ARG,
449                                 "[%s] Invalid argument is used. Timefield is less than 0 or grater than time field count.", GetErrorMessage(E_INVALID_ARG));
450
451         return __pCalendar->GetActualMinTimeField(field);
452 }
453
454 int
455 _CalendarImpl::GetGreatestMinTimeField(TimeField field) const
456 {
457         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
458         SysTryReturn(NID_LCL, ValidateTimeField(field), -1, E_INVALID_ARG,
459                                 "[%s] Invalid argument is used. Timefield is less than 0 or grater than time field count.", GetErrorMessage(E_INVALID_ARG));
460
461         return __pCalendar->GetGreatestMinTimeField(field);
462 }
463
464 int
465 _CalendarImpl::GetLeastMaxTimeField(TimeField field) const
466 {
467         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
468         SysTryReturn(NID_LCL, ValidateTimeField(field), -1, E_INVALID_ARG,
469                                 "[%s] Invalid argument is used. Timefield is less than 0 or grater than time field count.", GetErrorMessage(E_INVALID_ARG));
470
471         return __pCalendar->GetLeastMaxTimeField(field);
472 }
473
474 int
475 _CalendarImpl::GetActualMaxTimeField(TimeField field) const
476 {
477         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
478         SysTryReturn(NID_LCL, ValidateTimeField(field), -1, E_INVALID_ARG,
479                                 "[%s] Invalid argument is used. Timefield is less than 0 or grater than time field count.", GetErrorMessage(E_INVALID_ARG));
480
481         return __pCalendar->GetActualMaxTimeField(field);
482 }
483
484 int
485 _CalendarImpl::GetMaxTimeField(TimeField field) const
486 {
487         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
488         SysTryReturn(NID_LCL, ValidateTimeField(field), -1, E_INVALID_ARG,
489                                 "[%s] Invalid argument is used. Timefield is less than 0 or grater than time field count.", GetErrorMessage(E_INVALID_ARG));
490
491         return __pCalendar->GetMaxTimeField(field);
492 }
493
494 int
495 _CalendarImpl::GetFirstDayOfWeekImpl(void) const
496 {
497         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
498         return __pCalendar->GetFirstDayOfWeek();
499 }
500
501 int
502 _CalendarImpl::GetMinDaysInFirstWeekImpl(void) const
503 {
504         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
505         return __pCalendar->GetMinDaysInFirstWeek();
506 }
507
508 result
509 _CalendarImpl::IsInDst(bool& isInDst) const
510 {
511         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
512         return __pCalendar->IsInDst(isInDst);
513 }
514
515 bool
516 _CalendarImpl::IsLenientImpl(void) const
517 {
518         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
519         return __pCalendar->IsLenient();
520 }
521
522 bool
523 _CalendarImpl::IsSetImpl(TimeField field) const
524 {
525         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
526         return __pCalendar->IsSet(field);
527 }
528
529 TimeZone
530 _CalendarImpl::GetTimeZoneImpl(void) const
531 {
532         return __timezone;
533 }
534
535 bool
536 _CalendarImpl::IsLeapYear(int year) const
537 {
538         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
539         return __pCalendar->IsLeapYear(year);
540 }
541
542 result
543 _CalendarImpl::SetGregorianChange(long long change)
544 {
545         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
546         return __pCalendar->SetGregorianChange(change);
547 }
548
549 long long
550 _CalendarImpl::GetGregorianChange(void) const
551 {
552         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
553         return __pCalendar->GetGregorianChange();
554 }
555
556 result
557 _CalendarImpl::SetJulianDay(int julianDay)
558 {
559         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
560         return __pCalendar->SetJulianDay(julianDay);
561 }
562
563 int
564 _CalendarImpl::GetJulianDay(void) const
565 {
566         SysAssertf(__pCalendar != null, "Not yet constructed! Construct() should be called before use.");
567         return __pCalendar->GetJulianDay();
568 }
569
570 bool
571 _CalendarImpl::ValidateTimeField(TimeField field) const
572 {
573         if (field < 0 || field >= TIME_FIELD_FIELD_COUNT)
574         {
575                 return false;
576         }
577         return true;
578 }
579
580 bool
581 _CalendarImpl::ValidateTimeFieldValue(TimeField field, int value) const
582 {
583         if (IsLenientImpl() == false)
584         {
585                 if ((value < GetMinTimeField(field)) || (value > GetMaxTimeField(field)))
586                 {
587                         return false;
588                 }
589         }
590
591         return true;
592 }
593
594 bool
595 _CalendarImpl::ValidateDaysOfWeek(DayOfWeek dayOfWeek) const
596 {
597         if (dayOfWeek < SUNDAY || dayOfWeek > SATURDAY)
598         {
599                 return false;
600         }
601         return true;
602 }
603
604 // added for backward compatibility
605 result
606 _CalendarImpl::RollWithSingleUnit(TimeField field, bool up)
607 {
608         return E_UNSUPPORTED_OPERATION;
609 }
610
611 // added for backward compatibility
612 result
613 _CalendarImpl::ComputeTimeFields(void)
614 {
615         return E_UNSUPPORTED_OPERATION;
616 }
617
618 // added for backward compatibility
619 result
620 _CalendarImpl::ComputeTime(void)
621 {
622         return E_UNSUPPORTED_OPERATION;
623 }
624
625 // added for backward compatibility
626 int
627 _CalendarImpl::GetMonthLength(int extendedYear, int month) const
628 {
629         SetLastResult(E_UNSUPPORTED_OPERATION);
630         return -1;
631 }
632
633 // added for backward compatibility
634 int
635 _CalendarImpl::HandleGetLimit(TimeField field, CalendarLimitType limitType) const
636 {
637         SetLastResult(E_UNSUPPORTED_OPERATION);
638         return -1;
639 }
640
641 const _IcuCalendarImpl*
642 _CalendarImpl::GetImpl(const Calendar& calendar)
643 {
644         if (calendar._pCalendarImpl)
645         {
646                 return calendar._pCalendarImpl->__pCalendar;
647         }
648
649         return null;
650 }
651
652 };
653 };      // Tizen::Locales