[devel_3.0_main] Cherry-pick Beautification of source-code. 80383
[platform/framework/native/appfw.git] / src / base / FBaseDateTime.cpp
index 4a691d9..5195df3 100644 (file)
@@ -18,7 +18,6 @@
  * @file               FBaseDateTime.cpp
  * @brief              This file contains implementation of DateTime class
  */
-
 #include <stdlib.h>
 #include <wchar.h>
 #include <FBaseDateTime.h>
@@ -108,11 +107,11 @@ DateTime::SetValue(int year, int month, int day, int hour, int minute, int secon
 {
        SysTryReturn(NID_BASE,
                ((year >= MIN_YEAR && year <= _MAX_YEAR) &&
-                (month >= MIN_MONTH && month <= MAX_MONTH) &&
-                (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
-                (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
-                ((second & LOW_16BIT) >= MIN_SECOND && (second & LOW_16BIT) <= MAX_SECOND) &&
-                ((second >> INT_HALF_BIT) >= MIN_TICK && (second >> INT_HALF_BIT) <= MAX_TICK)),
+               (month >= MIN_MONTH && month <= MAX_MONTH) &&
+               (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
+               (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
+               ((second & LOW_16BIT) >= MIN_SECOND && (second & LOW_16BIT) <= MAX_SECOND) &&
+               ((second >> INT_HALF_BIT) >= MIN_TICK && (second >> INT_HALF_BIT) <= MAX_TICK)),
                E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), second(%d) and tick(%d) is out of allowable range.",
                GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second & LOW_16BIT, second >> INT_HALF_BIT);
@@ -137,11 +136,11 @@ DateTime::SetValue(int year, int month, int day, int hour, int minute, int secon
 {
        SysTryReturn(NID_BASE,
                ((year >= MIN_YEAR && year <= _MAX_YEAR) &&
-                (month >= MIN_MONTH && month <= MAX_MONTH) &&
-                (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
-                (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
-                (second >= MIN_SECOND && second <= MAX_SECOND) &&
-                ((millisecond * TICKS_PER_MILLISECOND >= MIN_TICK) && (millisecond * TICKS_PER_MILLISECOND <= MAX_TICK))),
+               (month >= MIN_MONTH && month <= MAX_MONTH) &&
+               (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
+               (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
+               (second >= MIN_SECOND && second <= MAX_SECOND) &&
+               ((millisecond * TICKS_PER_MILLISECOND >= MIN_TICK) && (millisecond * TICKS_PER_MILLISECOND <= MAX_TICK))),
                E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), second(%d) and tick(%d) is out of allowable range.",
                GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second, millisecond * TICKS_PER_MILLISECOND);
@@ -182,8 +181,8 @@ bool
 DateTime::operator ==(const DateTime& rhs) const
 {
        return((__dateTime.year == rhs.__dateTime.year) && (__dateTime.month == rhs.__dateTime.month)
-                       && (__dateTime.day == rhs.__dateTime.day) && (__dateTime.hour == rhs.__dateTime.hour) &&
-                       (__dateTime.minute == rhs.__dateTime.minute) && (__dateTime.second == rhs.__dateTime.second));
+               && (__dateTime.day == rhs.__dateTime.day) && (__dateTime.hour == rhs.__dateTime.hour) &&
+               (__dateTime.minute == rhs.__dateTime.minute) && (__dateTime.second == rhs.__dateTime.second));
 }
 
 bool
@@ -373,17 +372,17 @@ DateTime::AddMonths(int months)
        tmp.__dateTime.year += months / MAX_MONTH; // Get the year to add
 
        int tempMonth = tmp.__dateTime.month + months % MAX_MONTH;
-       if (tempMonth > MAX_MONTH)      // Month was added and moved to next year
+       if (tempMonth > MAX_MONTH)  // Month was added and moved to next year
        {
                tmp.__dateTime.year++;
                tmp.__dateTime.month = tempMonth - MAX_MONTH;
        }
-       else if (tempMonth <= 0)        // Month was subtracted and moved to previous year
+       else if (tempMonth <= 0)    // Month was subtracted and moved to previous year
        {
                tmp.__dateTime.year--;
                tmp.__dateTime.month = MAX_MONTH + tempMonth;
        }
-       else                                            // Keep current year
+       else                        // Keep current year
        {
                tmp.__dateTime.month += months % MAX_MONTH;
        }
@@ -391,26 +390,26 @@ DateTime::AddMonths(int months)
        // Check the days in Month
        if (tmp.__dateTime.month != 2)      // Current month is not Feb
        {
-               if (tmp.__dateTime.day == 31)   // Previous day is 31th
+               if (tmp.__dateTime.day == 31)   // Previous day is 31th
                {
                        result r = SetValue(tmp.__dateTime.year, tmp.__dateTime.month, tmp.__dateTime.day);
-                       if (IsFailed(r))                        // Current month doesn't have 31th
+                       if (IsFailed(r))            // Current month doesn't have 31th
                        {
-                               tmp.__dateTime.day = 30;        // Set day to 30th
+                               tmp.__dateTime.day = 30;    // Set day to 30th
                        }
                }
        }
-       else                                                                    // Current month is Feb
+       else                                    // Current month is Feb
        {
-               if (tmp.__dateTime.day > 28)            // Previous day is over 28th
+               if (tmp.__dateTime.day > 28)        // Previous day is over 28th
                {
-                       if (tmp.IsLeapYear())                   // Leap year
+                       if (tmp.IsLeapYear())           // Leap year
                        {
-                               tmp.__dateTime.day = 29;        // Set day to 29th
+                               tmp.__dateTime.day = 29;    // Set day to 29th
                        }
-                       else                                                    // Not leap year
+                       else                            // Not leap year
                        {
-                               tmp.__dateTime.day = 28;        // Set day to 28th
+                               tmp.__dateTime.day = 28;    // Set day to 28th
                        }
                }
        }
@@ -516,7 +515,7 @@ DateTime::CompareTo(const DateTime& value) const
 bool
 DateTime::Equals(const Object& obj) const
 {
-       const DateTime* pOther = dynamic_cast <const DateTime*>(&obj);
+       const DateTime* pOther = dynamic_cast< const DateTime* >(&obj);
        if (pOther == null)
        {
                return false;
@@ -602,8 +601,8 @@ DateTime::ToString(void) const
        wchar_t date[] = L"01/01/1970 00:00:00";
 
        swprintf(date, (sizeof(date) / sizeof(wchar_t)), L"%2d/%2d/%4d %2d:%2d:%2d",
-                        __dateTime.month, __dateTime.day, __dateTime.year, __dateTime.hour, __dateTime.minute,
-                        (__dateTime.second & LOW_16BIT));
+               __dateTime.month, __dateTime.day, __dateTime.year, __dateTime.hour, __dateTime.minute,
+               (__dateTime.second & LOW_16BIT));
 
        if (__dateTime.month < 10)
        {
@@ -658,7 +657,7 @@ DateTime::Parse(const String& str, DateTime& dt)
                E_INVALID_FORMAT, E_INVALID_FORMAT, ("[%s] The str(%s) is not formatted like 'mm/dd/yyyy hh:mm:ss'."),
                GetErrorMessage(E_INVALID_FORMAT), str.GetPointer());
 
-       std::unique_ptr<wchar_t []> pTmp(new (std::nothrow) wchar_t [5]);
+       std::unique_ptr< wchar_t[] > pTmp(new (std::nothrow) wchar_t[5]);
        SysTryReturn(NID_BASE, pTmp != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -955,5 +954,3 @@ DateTime::ConvertDateToSeconds(const TmDateTime* pDateTime) const
 }
 
 }} // Tizen::Base
-
-