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";
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;
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)
{
{
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)
{
if ((dayOfStartTime & weekEnd) != 0)
{
- count += (interval - 1) * _CALENDARBOOK_NUMBER_OF_DAYS_OF_WEEK;
+ count += (interval - 1) * _NUMBER_OF_DAYS_OF_WEEK;
}
dayOfStartTime = GetNextDayOfWeek(dayOfStartTime);
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)
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;
}
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;
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;
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)
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;
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)
{
{
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));