diff options
author | Hosang Kim <hosang.kim@samsung.com> | 2013-04-16 02:53:53 +0900 |
---|---|---|
committer | Hosang Kim <hosang.kim@samsung.com> | 2013-04-16 03:35:07 +0900 |
commit | f8f9626cd72d5d849d2306185765a1b42de724d0 (patch) | |
tree | 109f5555c09efb03ffa6ccc1e9bed3614e8cceab | |
parent | b716dcd3d3fc8ce96fc84cba786f146e96d8d443 (diff) | |
download | social-f8f9626cd72d5d849d2306185765a1b42de724d0.tar.gz social-f8f9626cd72d5d849d2306185765a1b42de724d0.tar.bz2 social-f8f9626cd72d5d849d2306185765a1b42de724d0.zip |
[DCM-1303] Fixed recurrence logic
Change-Id: Id31ffc8e4014efe15a7dcfcf7b64eddcb5a7f9b1
Signed-off-by: Hosang Kim <hosang.kim@samsung.com>
-rw-r--r-- | src/FScl_CalEventImpl.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/FScl_CalEventImpl.cpp b/src/FScl_CalEventImpl.cpp index c1e5f0a..3221069 100644 --- a/src/FScl_CalEventImpl.cpp +++ b/src/FScl_CalEventImpl.cpp @@ -57,7 +57,7 @@ static const int _TERM_LIMIT_DAILY = 1; static const int _TERM_LIMIT_WEEKLY = 7; static const int _TERM_LIMIT_MONTHLY = 31; static const int _TERM_LIMIT_YEARLY = 366; -static const int _CALENDARBOOK_NUMBER_OF_DAYS_OF_WEEK = 7; +static const int _NUMBER_OF_DAYS_OF_WEEK = 7; static const wchar_t* _EVENT_CATEGORY_APPOINTMENT_STRING = L"Appointment"; static const wchar_t* _EVENT_CATEGORY_ANNIVERSARY_STRING = L"Anniversary"; @@ -77,8 +77,7 @@ static const wchar_t _RECURRENCE_BY_DAY_CHAR_MINUS = L'-'; static const wchar_t _RECURRENCE_BY_DAY_CHAR_ONE = L'1'; static const int _RECURRENCE_BY_DAY_FIRST_INDEX = 0; static const int _RECURRENCE_BY_DAY_SECOND_INDEX = 1; -static const int _MAX_WEEK_OF_RECURRENCE_BY_DAY = 5; -static const int _RECURRENCE_NUMBER_OF_WEEK_DAY = 7; +static const int _MAX_WEEK_OF_MONTH = 5; static const double _MIN_LATITUDE = -90.0; static const double _MAX_LATITUDE = 90.0; @@ -1580,7 +1579,7 @@ _CalEventImpl::ConvertDayOfWeekToRRuleByDayString(int dayOfWeek, int weekOfMonth int tmpDayOfWeek = CAL_SUNDAY; byDayString.Clear(); - for (int i = 0; i < _RECURRENCE_NUMBER_OF_WEEK_DAY; i++) + for (int i = 0; i < _NUMBER_OF_DAYS_OF_WEEK; i++) { if (dayOfWeek & tmpDayOfWeek) { @@ -1805,7 +1804,7 @@ _CalEventImpl::ResetStartAndEndTimeByRecurrence(const Recurrence& recurrence) { int count = 0; - for (int i = 0; i < _CALENDARBOOK_NUMBER_OF_DAYS_OF_WEEK; i++) + for (int i = 0; i < _NUMBER_OF_DAYS_OF_WEEK; i++) { if ((dayOfStartTime & dayOfWeek) != 0) { @@ -1814,7 +1813,7 @@ _CalEventImpl::ResetStartAndEndTimeByRecurrence(const Recurrence& recurrence) if ((dayOfStartTime & weekEnd) != 0) { - count += (interval - 1) * _CALENDARBOOK_NUMBER_OF_DAYS_OF_WEEK; + count += (interval - 1) * _NUMBER_OF_DAYS_OF_WEEK; } dayOfStartTime = GetNextDayOfWeek(dayOfStartTime); @@ -2025,7 +2024,7 @@ _CalEventImpl::ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(const String& by r = token.GetCharAt(_RECURRENCE_BY_DAY_FIRST_INDEX, tmpChar); if (tmpChar == _RECURRENCE_BY_DAY_CHAR_MINUS) { - SysTryReturnResult(NID_SCL, weekOfMonth == 0 || weekOfMonth == _MAX_WEEK_OF_RECURRENCE_BY_DAY + SysTryReturnResult(NID_SCL, weekOfMonth == 0 || weekOfMonth == _MAX_WEEK_OF_MONTH , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer()); if (weekOfMonth == 0) @@ -2035,7 +2034,7 @@ _CalEventImpl::ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(const String& by SysTryReturnResult(NID_SCL, tmpChar == _RECURRENCE_BY_DAY_CHAR_ONE , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer()); - weekOfMonth = _MAX_WEEK_OF_RECURRENCE_BY_DAY; + weekOfMonth = _MAX_WEEK_OF_MONTH; } weekStringStartIndex = _RECURRENCE_BY_DAY_SECOND_INDEX + 1; } @@ -2046,7 +2045,7 @@ _CalEventImpl::ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(const String& by tmpChar = 0; r = token.GetCharAt(_RECURRENCE_BY_DAY_SECOND_INDEX, tmpChar); tmpWeekOfMonth = Character::ToDigit(tmpChar, Character::RADIX_DECIMAL); - SysTryReturnResult(NID_SCL, tmpWeekOfMonth > 0 && tmpWeekOfMonth <= _MAX_WEEK_OF_RECURRENCE_BY_DAY + SysTryReturnResult(NID_SCL, tmpWeekOfMonth > 0 && tmpWeekOfMonth <= _MAX_WEEK_OF_MONTH , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer()); weekOfMonth = tmpWeekOfMonth; @@ -2064,7 +2063,7 @@ _CalEventImpl::ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(const String& by if (weekOfMonth == 0) { tmpWeekOfMonth = Character::ToDigit(tmpChar, Character::RADIX_DECIMAL); - SysTryReturnResult(NID_SCL, tmpWeekOfMonth > 0 && tmpWeekOfMonth <= _MAX_WEEK_OF_RECURRENCE_BY_DAY + SysTryReturnResult(NID_SCL, tmpWeekOfMonth > 0 && tmpWeekOfMonth <= _MAX_WEEK_OF_MONTH , E_INVALID_ARG, "Invalid argument is passed. byday = %S", byDay.GetPointer()); weekOfMonth = tmpWeekOfMonth; @@ -2198,8 +2197,6 @@ _CalEventImpl::GetNextDayOfWeek(CalDayOfWeek currentDay) DateTime _CalEventImpl::GetDate(int year, int month, int weekOfMonth, CalDayOfWeek dayOfWeek, const DateTime& time, const Locales::TimeZone& timeZone) { - DateTime resultTime; - Tizen::Locales::DayOfWeek dayOfWeekByGregorianCalendar = Tizen::Locales::DAY_OF_WEEK_UNDEFINED; switch (dayOfWeek) @@ -2233,20 +2230,20 @@ _CalEventImpl::GetDate(int year, int month, int weekOfMonth, CalDayOfWeek dayOfW pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_YEAR, year); pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_MONTH, month); - pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_DAY_OF_WEEK, dayOfWeekByGregorianCalendar); - pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_WEEK_OF_MONTH, weekOfMonth); + pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_DAY_OF_MONTH, 1); - resultTime = pGregorianCalendar->GetTime(); + Tizen::Locales::DayOfWeek tmpDayOfWeek = static_cast<Tizen::Locales::DayOfWeek>(pGregorianCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK)); + int maxDaysOfMonth = pGregorianCalendar->GetActualMaxTimeField(TIME_FIELD_DAY_OF_MONTH); + int tmpDayOfMonth = ((_NUMBER_OF_DAYS_OF_WEEK + dayOfWeekByGregorianCalendar) - tmpDayOfWeek) % _NUMBER_OF_DAYS_OF_WEEK + 1; - if (month != resultTime.GetMonth()) + tmpDayOfMonth += ((weekOfMonth - 1) * _NUMBER_OF_DAYS_OF_WEEK); + if (tmpDayOfMonth > maxDaysOfMonth) { - pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_YEAR, year); - pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_MONTH, month); - pGregorianCalendar->SetTimeField(Tizen::Locales::TIME_FIELD_WEEK_OF_MONTH, _MAX_WEEK_OF_RECURRENCE_BY_DAY - 1); - resultTime = pGregorianCalendar->GetTime(); + tmpDayOfMonth -= _NUMBER_OF_DAYS_OF_WEEK; } - resultTime.SetValue(resultTime.GetYear(), resultTime.GetMonth(), resultTime.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond()); + DateTime resultTime; + resultTime.SetValue(year, month, tmpDayOfMonth, time.GetHour(), time.GetMinute(), time.GetSecond()); delete pGregorianCalendar; @@ -2300,7 +2297,7 @@ _CalEventImpl::GetFirstDay(CalDayOfWeek weekStart, int dayOfWeek, int& count) int tmpDay = weekStart; count = 0; - for (int i = 0; i < _CALENDARBOOK_NUMBER_OF_DAYS_OF_WEEK; i++) + for (int i = 0; i < _NUMBER_OF_DAYS_OF_WEEK; i++) { if ((tmpDay & dayOfWeek) != 0) { @@ -2323,7 +2320,7 @@ _CalEventImpl::GetNextDay(int dayOfWeek, CalDayOfWeek currentDay) { int tmpDay = currentDay; - for (int i = 0; i < _CALENDARBOOK_NUMBER_OF_DAYS_OF_WEEK; i++) + for (int i = 0; i < _NUMBER_OF_DAYS_OF_WEEK; i++) { tmpDay = GetNextDayOfWeek(static_cast<CalDayOfWeek>(tmpDay)); |