Fix for EditDate/EditTime random crash
authorPrakalathan Ponnusamy <prakalath.p@samsung.com>
Tue, 11 Jun 2013 07:49:23 +0000 (13:19 +0530)
committerPrakalathan Ponnusamy <prakalath.p@samsung.com>
Tue, 11 Jun 2013 07:49:23 +0000 (13:19 +0530)
Change-Id: I72b88b3814afe40959a31eb9c5abec9283cda937

src/ui/controls/FUiCtrl_DateTimeUtils.cpp
src/ui/inc/FUiCtrl_DateTimeUtils.h

index 66dfd09..31fad89 100644 (file)
@@ -48,11 +48,18 @@ _DateTimeUtils::_DateTimeUtils(void)
 const String
 _DateTimeUtils::GetMonthString(int month) const
 {
+       result r = E_SUCCESS;
        String text;
        text.Clear();
 
        DateTimeSymbols dateSymbols;
-       dateSymbols.Construct(CALENDAR_GREGORIAN);
+       r = dateSymbols.Construct(CALENDAR_GREGORIAN);
+
+       if (r != E_SUCCESS)
+       {
+               text.Append(GetEnglishMonthString(month));
+               return text;
+       }
 
        const IList* pListOfShortMonths = dateSymbols.GetShortMonths();
        SysTryReturn(NID_UI_CTRL, (pListOfShortMonths != null), text, E_SYSTEM, "[E_SYSTEM] A system error has occurred. pListOfShortMonths is null.");
@@ -68,6 +75,67 @@ _DateTimeUtils::GetMonthString(int month) const
        return text;
 }
 
+const String
+_DateTimeUtils::GetEnglishMonthString(int month) const
+{
+       String text;
+       text.Clear();
+       switch (month)
+       {
+       case 1:
+               text.Append("Jan");
+               break;
+
+       case 2:
+               text.Append("Feb");
+               break;
+
+       case 3:
+               text.Append("Mar");
+               break;
+
+       case 4:
+               text.Append("Apr");
+               break;
+
+       case 5:
+               text.Append("May");
+               break;
+
+       case 6:
+               text.Append("Jun");
+               break;
+
+       case 7:
+               text.Append("Jul");
+               break;
+
+       case 8:
+               text.Append("Aug");
+               break;
+
+       case 9:
+               text.Append("Sep");
+               break;
+
+       case 10:
+               text.Append("Oct");
+               break;
+
+       case 11:
+               text.Append("Nov");
+               break;
+
+       case 12:
+               text.Append("Dec");
+               break;
+
+       default:
+               break;
+       }
+       return text;
+}
+
 int
 _DateTimeUtils::CalculateMaxDay(int displayYear, int month) const
 {
@@ -117,8 +185,23 @@ _DateTimeUtils::IsLeapYear(int year) const
 void
 _DateTimeUtils::GetAmPm(String& timeFormat, _AmPmType amPmType) const
 {
+       result r = E_SUCCESS;
        DateTimeSymbols dateSymbols;
-       dateSymbols.Construct(CALENDAR_GREGORIAN);
+
+       r = dateSymbols.Construct(CALENDAR_GREGORIAN);
+
+       if (r != E_SUCCESS)
+       {
+               if (amPmType == AM_TYPE)
+               {
+                       timeFormat.Append("AM");
+               }
+               else
+               {
+                       timeFormat.Append("PM");
+               }
+               return;
+       }
 
        const IList* pListOfAmPm = dateSymbols.GetAmPm();
        SysTryReturnVoidResult(NID_UI_CTRL, (pListOfAmPm != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. pListOfAmPm is null.");
index ac2eb1f..8848cd9 100644 (file)
@@ -46,6 +46,7 @@ public:
 // Operations
 public:
        const Tizen::Base::String GetMonthString(int month) const;
+       const Tizen::Base::String GetEnglishMonthString(int month) const;
        const Tizen::Base::String GetFullMonthString(int month) const;
        int CalculateMaxDay(int displayYear, int month) const ;
        bool IsLeapYear(int year) const;