pimappservices/calendar/client/src/calrrule.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <calrrule.h>
       
    17 
       
    18 #include "agmutil.h"
       
    19 #include "calcommonimpl.h"
       
    20 
       
    21 /** Constructor for the weekday within a month data structure.
       
    22 
       
    23 @param aDay The weekday to set.
       
    24 @param aWeekInMonth The week to set. 
       
    25 
       
    26 @publishedAll
       
    27 @released
       
    28 @capability None
       
    29 */
       
    30 EXPORT_C TCalRRule::TDayOfMonth::TDayOfMonth(TDay aDay, TInt8 aWeekInMonth) :
       
    31 	iDay(aDay), iWeekInMonth(aWeekInMonth)
       
    32 	{
       
    33 	}
       
    34 
       
    35 /** Get the weekday.
       
    36 @return The weekday.
       
    37 
       
    38 @publishedAll
       
    39 @released 
       
    40 @capability None
       
    41 */
       
    42 EXPORT_C TDay TCalRRule::TDayOfMonth::Day() const
       
    43 	{
       
    44 	return iDay;
       
    45 	}
       
    46 
       
    47 /** Get the week within the month.
       
    48 @return The week within the month.
       
    49 
       
    50 @publishedAll
       
    51 @released 
       
    52 @capability None
       
    53 */
       
    54 EXPORT_C TInt8 TCalRRule::TDayOfMonth::WeekInMonth() const
       
    55 	{
       
    56 	return iWeekInMonth;
       
    57 	}
       
    58 
       
    59 // Some bits are used internally to differentiate between rule types:
       
    60 //  if bit 63 is set on a monthly rule, then it is week-of-month format, e.g. 3rd Wed
       
    61 //  if bit 63 is not set on a monthly rule, then it is date-of-month format, e.g. 10th
       
    62 const TUint KMonthlyByWeek = 63;
       
    63 
       
    64 //  if bit 62 is set on a yearly rule, then it is week-of-month-of-year format, e.g. 3rd Wed of June
       
    65 //  if bit 62 is not set on a yearly rule, then it is date-of-year format, e.g. 10th June
       
    66 const TUint KYearlyByWeek = 62;
       
    67 
       
    68 // Provides a mapping between the numbers 0 to 63 to bit fields.
       
    69 // 0 maps to EBit1
       
    70 // 1 maps to EBit2
       
    71 // ...etc
       
    72 TBool TCalRRule::GetNthBit(TUint aNum) const
       
    73 	{
       
    74 	TUint64 bit(EBit1);
       
    75 	
       
    76 	if (aNum >= 64)
       
    77 		{
       
    78 		CalUtils::Panic(ERepeatRuleBitFailure);
       
    79 		}
       
    80 	
       
    81 	bit = bit << aNum;
       
    82 	
       
    83 	if (iBuffer & bit)
       
    84 		{
       
    85 		return ETrue;
       
    86 		}
       
    87 	return EFalse;
       
    88 	}
       
    89 
       
    90 void TCalRRule::SetNthBit(TUint aNum)
       
    91 	{
       
    92 	TUint64 bit(EBit1);
       
    93 	
       
    94 	if (aNum >= 64)
       
    95 		{
       
    96 		CalUtils::Panic(ERepeatRuleBitFailure);
       
    97 		}
       
    98 	
       
    99 	bit = bit << aNum;
       
   100 	
       
   101 	iBuffer |= bit;
       
   102 	}
       
   103 
       
   104 /** Constructor for the iCal repeat rule type.
       
   105 This does not set the type. All data is reset.
       
   106  
       
   107 @publishedAll
       
   108 @released
       
   109 @capability None
       
   110 */
       
   111 EXPORT_C TCalRRule::TCalRRule()
       
   112 	{
       
   113 	iType = EInvalid;
       
   114 	InitialiseData();
       
   115 	}
       
   116 
       
   117 /** Constructor for the iCal repeat rule type.
       
   118 All data is reset.
       
   119 
       
   120 @leave KErrNotSupported If an invalid repeat rule type is passed in.
       
   121 
       
   122 @param aType The type of repeat rule. One of: EDaily, EWeekly, EMonthly, EYearly. 
       
   123 
       
   124 @publishedAll
       
   125 @released
       
   126 @capability None
       
   127 */
       
   128 EXPORT_C TCalRRule::TCalRRule(TCalRRule::TType aType)
       
   129 	{
       
   130 	__ASSERT_ALWAYS(aType == EDaily || aType == EWeekly || aType == EMonthly || aType == EYearly, 
       
   131 						Panic(EAgmErrBadRepeat));
       
   132 	iType = aType;
       
   133 	InitialiseData();
       
   134 	}
       
   135 
       
   136 void TCalRRule::InitialiseData()
       
   137 	{
       
   138 	iBuffer = 0;
       
   139 	iCount = 0;
       
   140 	iUntil.SetTimeUtcL(Time::NullTTime()); // this can't leave
       
   141 	iInterval = 1;
       
   142 	TLocale locale;
       
   143 	iWkSt = locale.StartOfWeek();
       
   144 	iReserved = 0;
       
   145 	iReserved2 = 0;
       
   146 	}
       
   147 
       
   148 /** Sets the repeat definition's type.
       
   149 
       
   150 This will be one of: daily, weekly, monthly or yearly. If the type is weekly,
       
   151 it must have at least one weekday set by calling SetByDay().
       
   152 
       
   153 The type may only be set once, from either the constructor or from the SetType function. 
       
   154 @leave KErrNotSupported If an invalid type is passed in.
       
   155 @panic CalInterimAPI 15 The repeat rule type has already been set.
       
   156 @param aType The repeat definition's type. 
       
   157 @see SetByDay()
       
   158 @publishedAll
       
   159 @released 
       
   160 @capability None
       
   161 */
       
   162 EXPORT_C void TCalRRule::SetType(TCalRRule::TType aType)
       
   163 	{
       
   164 	__ASSERT_ALWAYS(iType == EInvalid, CalUtils::Panic(ERepeatRuleTypeAlreadySet)); // type must not be set already
       
   165 	__ASSERT_ALWAYS(aType == EDaily || aType == EWeekly || aType == EMonthly || aType == EYearly, 
       
   166 			User::Leave(KErrNotSupported)); // aType must be a meaningful type	
       
   167 	iType = aType;
       
   168 	}
       
   169 
       
   170 /** Gets the repeat definition's type. 
       
   171 
       
   172 This will be one of: daily, weekly, monthly or yearly.
       
   173 
       
   174 @return The repeat definition's type. 
       
   175 @publishedAll
       
   176 @released 
       
   177 @capability None
       
   178 */
       
   179 EXPORT_C TCalRRule::TType TCalRRule::Type() const
       
   180 	{
       
   181 	return iType;
       
   182 	}
       
   183 
       
   184 /** Sets the repeat's start date.
       
   185 
       
   186 The repeat rule's start date should match the entry's start date. If it does
       
   187 not then it will be modified to match the entry's start date (or end date for Todos)
       
   188 when the rule is applied to the entry using CCalEntry::SetRRuleL.
       
   189 
       
   190 @param aStartDate The start date, as a TCalTime so it may be accessed in utc or system local time. 
       
   191 @publishedAll
       
   192 @released 
       
   193 @capability None
       
   194 */
       
   195 EXPORT_C void TCalRRule::SetDtStart(const TCalTime& aStartDate)
       
   196 	{
       
   197 	iDtStart = aStartDate;
       
   198 	}
       
   199 	
       
   200 /** Gets the date on which this repeat rule starts.
       
   201 
       
   202 @return The start date, as a TCalTime so it may be accessed in utc or system local time. 
       
   203 @publishedAll
       
   204 @released 
       
   205 @capability None
       
   206 */
       
   207 EXPORT_C TCalTime TCalRRule::DtStart() const
       
   208 	{ 	
       
   209 	return iDtStart; 
       
   210 	}
       
   211 
       
   212 /** Sets the repeat's end date. 
       
   213 
       
   214 Only one of the until or count parameters may be set. Setting the until date will reset the count parameter.
       
   215 If the until date is set to TCalTime::MaxTime() the rule will repeat forever.
       
   216 
       
   217 @param aEndDate The end date, as a TCalTime so it may be accessed in utc or system local time. 
       
   218 @publishedAll
       
   219 @released 
       
   220 @capability None
       
   221 */
       
   222 EXPORT_C void TCalRRule::SetUntil(const TCalTime& aEndDate)
       
   223 	{
       
   224 	//"-1" means only until time has been set 
       
   225 	iCount = -1;	
       
   226 
       
   227 
       
   228 	if (aEndDate.TimeUtcL() == TCalTime::MaxTime() || aEndDate.TimeLocalL() == TCalTime::MaxTime())
       
   229 		{
       
   230 		iCount = 0;	
       
   231 		}
       
   232 
       
   233 	iUntil = aEndDate;
       
   234 	}
       
   235 	
       
   236 /** Gets the date on which this repeat rule finishes.
       
   237 
       
   238 @return The end date, as a TCalTime so it may be accessed in utc or system local time. If 
       
   239 the until value has not been set this will return Time::NullTTime.
       
   240 @publishedAll
       
   241 @released 
       
   242 @capability None
       
   243 */
       
   244 EXPORT_C TCalTime TCalRRule::Until() const
       
   245 	{
       
   246 	return iUntil; 
       
   247 	}
       
   248 
       
   249 /** Sets the repeat interval. 
       
   250 
       
   251 This is a number of days for a daily repeat, a number of weeks for a 
       
   252 weekly repeat, etc. 
       
   253 
       
   254 @param aInterval The interval. Any parameter that is greater than 255 or less than 1 will be ignored.
       
   255 @publishedAll
       
   256 @released 
       
   257 @capability None
       
   258 */
       
   259 EXPORT_C void TCalRRule::SetInterval(TInt aInterval)
       
   260 	{
       
   261 	if (aInterval > 0 && aInterval < 256)
       
   262 		{
       
   263 		iInterval = aInterval;
       
   264 		}
       
   265 	}
       
   266 
       
   267 /** Gets the repeat interval.
       
   268 
       
   269 This is a number of days for a daily repeat, a number of weeks for a 
       
   270 weekly repeat, etc. 
       
   271 
       
   272 @return The interval. 
       
   273 @publishedAll
       
   274 @released 
       
   275 @capability None
       
   276 */
       
   277 EXPORT_C TInt TCalRRule::Interval() const
       
   278 	{
       
   279 	return iInterval;
       
   280 	}
       
   281 
       
   282 /** Sets the number of instances that this repeat rule will contain. Setting the count
       
   283  	will reset the until time to Time::NullTTime.
       
   284 
       
   285 @param aCount The number of instances. Any non-positive parameter will be ignored.
       
   286 @publishedAll
       
   287 @released 
       
   288 @capability None
       
   289 */
       
   290 EXPORT_C void TCalRRule::SetCount(TUint aCount)
       
   291 	{
       
   292 	if (aCount > 0)
       
   293 		{
       
   294 		iCount = aCount;
       
   295 		
       
   296 		if(iUntil.TimeLocalL() != Time::NullTTime())
       
   297 			{
       
   298 			iUntil.SetTimeLocalL(Time::NullTTime());
       
   299 			}	
       
   300 		}
       
   301 	}
       
   302 
       
   303 /** Gets the number of instances that this repeat rule will contain.
       
   304 
       
   305 @return The number of instances. It will return:
       
   306 
       
   307 >0 - Indicate how many occurrences of a repeating rule.
       
   308  0 - Repeating forever. Note that it is the default value if there is neither Until time nor Count has been set. 
       
   309 <0 - A Until time has been set but not the count. 
       
   310 
       
   311 @publishedAll
       
   312 @released 
       
   313 @capability None
       
   314 */
       
   315 EXPORT_C TUint TCalRRule::Count() const
       
   316 	{
       
   317 	return iCount;
       
   318 	}
       
   319 	
       
   320 /** Set all weekdays on which this rule is repeated.
       
   321 
       
   322 @leave KErrNotSupported if not called on a weekly repeat rule.
       
   323 @param aDays Array containing all weekdays that are to be set. Any weekdays not included 
       
   324 in this array will not be set. Any weekdays not in the TDay enum will be ignored. 
       
   325 @publishedAll
       
   326 @released
       
   327 @capability None
       
   328 */
       
   329 EXPORT_C void TCalRRule::SetByDay(const RArray<TDay>& aDays)
       
   330 	{
       
   331 	__ASSERT_ALWAYS(iType == EWeekly, User::Leave(KErrNotSupported));
       
   332 	
       
   333 	iBuffer = 0;
       
   334 	
       
   335 	TInt daysCount = aDays.Count();
       
   336 	for (TInt i = 0; i < daysCount; ++i)
       
   337 		{
       
   338 		TDay day(aDays[i]);
       
   339 		if (day >= EMonday && day <= ESunday)
       
   340 			{
       
   341 			// if this day is valid then set this bit
       
   342 			SetNthBit(static_cast<TUint>(day));
       
   343 			}
       
   344 		}
       
   345 	}
       
   346 
       
   347 /** Gets all weekdays on which this rule is repeated.
       
   348 
       
   349 @param aDays On return this array contains all weekdays that are to be set. 
       
   350 This function will do nothing if this is not a weekly repeat rule. 
       
   351 @publishedAll
       
   352 @released 
       
   353 @capability None
       
   354 */
       
   355 EXPORT_C void TCalRRule::GetByDayL(RArray<TDay>& aDays) const
       
   356 	{
       
   357 	if (iType == EWeekly)
       
   358 		{
       
   359 		aDays.Reset();
       
   360 		TDay day = EMonday;
       
   361 		while(day <= ESunday)
       
   362 			{
       
   363 			if (GetNthBit(static_cast<TUint>(day)))
       
   364 				{
       
   365 				aDays.AppendL(day);
       
   366 				}
       
   367 			day = static_cast<TDay>((static_cast<TInt>(day) + 1));
       
   368 			}
       
   369 		}
       
   370 	}
       
   371 
       
   372 /** Set all weekdays in the month on which this rule is repeated.
       
   373 
       
   374 @leave KErrNotSupported If it is called on a repeat rule which is not monthly or yearly.
       
   375 
       
   376 @param aDays Array containing all days in the month that are to be set. Any days in the month
       
   377 not included in this array will not be set. For a yearly rule, only the first item in the array 
       
   378 will be used. Any invalid data will be ignored. 
       
   379 @publishedAll
       
   380 @released
       
   381 @capability None
       
   382 */
       
   383 EXPORT_C void TCalRRule::SetByDay(const RArray<TDayOfMonth>& aDays)
       
   384 	{
       
   385 	__ASSERT_ALWAYS(iType == EMonthly || iType == EYearly, User::Leave(KErrNotSupported));
       
   386 		
       
   387 	if (iType == EMonthly)
       
   388 		{
       
   389 		iBuffer = 0;
       
   390 		TInt daysCount = aDays.Count();
       
   391 		for (TInt i = 0; i < daysCount; ++i)
       
   392 			{
       
   393 			TDayOfMonth dayOfMonth = aDays[i];
       
   394 			TDay weekDay = dayOfMonth.Day();
       
   395 			if (weekDay >= EMonday && weekDay <= ESunday)
       
   396 				{
       
   397 				TInt byteToSet = dayOfMonth.WeekInMonth();
       
   398 				// if this day and week are valid then set this bit
       
   399 				if (byteToSet == -1 || (byteToSet >= 1 && byteToSet <= 4))
       
   400 					{
       
   401 					if (byteToSet == -1)
       
   402 						{
       
   403 						byteToSet = 0;
       
   404 						}
       
   405 					
       
   406 					// first 7 bits represent which weekdays are set on the last week of the month - (week = -1)
       
   407 					// next 7 bits represent which weekdays are set on the 1st week of the month - (week = 1)
       
   408 					// next 7 bits represent which weekdays are set on the 2nd week of the month - (week = 2)
       
   409 					// next 7 bits represent which weekdays are set on the 3rd week of the month - (week = 3)
       
   410 					// next 7 bits represent which weekdays are set on the 4th week of the month - (week = 4)
       
   411 					TUint bitToSet = weekDay + 7 * byteToSet;
       
   412 					SetNthBit(bitToSet);
       
   413 					}
       
   414 				}
       
   415 			}
       
   416 		SetNthBit(KMonthlyByWeek);
       
   417 		}
       
   418 	else if (iType == EYearly)
       
   419 		{
       
   420 		if (!GetNthBit(KYearlyByWeek))
       
   421 			{
       
   422 			iBuffer = 0;
       
   423 			SetNthBit(KYearlyByWeek);
       
   424 			}
       
   425 			
       
   426 		if (aDays.Count() >= 1)
       
   427 			{
       
   428 			TDay theDay = aDays[0].Day();
       
   429 			TInt8 theWeek = aDays[0].WeekInMonth();
       
   430 			
       
   431 			if (theDay >= EMonday && theDay <= ESunday && 
       
   432 				(theWeek == -1 || (theWeek >= 1 && theWeek <= 4)) )
       
   433 				{
       
   434 				TUint8* bufferPtr = (TUint8*)&iBuffer; // convert the iBuffer store to three TUint8s
       
   435 				// EMonday=0 so store it as 1, this allows us to tell if any days have been set
       
   436 				bufferPtr[0] = (TUint8)theDay+1;
       
   437 				bufferPtr[1] = (TUint8)theWeek;
       
   438 				}
       
   439 			}
       
   440 		}
       
   441 	}
       
   442 
       
   443 /** Gets all days in the month on which this rule is repeated.
       
   444 
       
   445 @param aDays On return this array contains all days in the month that are to be set. 
       
   446 This function will do nothing if this is not a monthly or yearly repeat rule. 
       
   447 @publishedAll
       
   448 @released 
       
   449 @capability None
       
   450 */
       
   451 EXPORT_C void TCalRRule::GetByDayL(RArray<TDayOfMonth>& aDays) const
       
   452 	{
       
   453 	if (iType == EMonthly)
       
   454 		{
       
   455 		aDays.Reset();
       
   456 		if (GetNthBit(KMonthlyByWeek))
       
   457 			{
       
   458 			// if i == 35, then weekNum = 5 below which is too high
       
   459 			for (TUint i = 0; i < 35; ++i)
       
   460 				{
       
   461 				if (GetNthBit(i))
       
   462 					{
       
   463 					// This is the reverse of the algorithm in TCalRRule::SetByDay(const RArray<TDayOfMonth>& aDays)
       
   464 					TDay day = static_cast<TDay>(i % 7);
       
   465 					TInt weekNum = i / 7;
       
   466 					if (weekNum == 0)
       
   467 						{
       
   468 						weekNum = -1;
       
   469 						}
       
   470 					TDayOfMonth dayOfMonth(day, weekNum);
       
   471 					aDays.AppendL(dayOfMonth);
       
   472 					}
       
   473 				}
       
   474 			}
       
   475 		}
       
   476 	else if (iType == EYearly)
       
   477 		{
       
   478 		aDays.Reset();
       
   479 		if (GetNthBit(KYearlyByWeek))
       
   480 			{
       
   481 			TUint8* bufferPtr = (TUint8*)&iBuffer; // convert the iBuffer store to three TUint8s
       
   482 			TDay theDay = TDay(bufferPtr[0]-1); // -1 because EMonday is stored as +1
       
   483 			TInt8 theWeek = TInt8(bufferPtr[1]);
       
   484 			
       
   485 			if (theDay >= EMonday && theDay <= ESunday)
       
   486 				{
       
   487 				TDayOfMonth dayOfMonth(theDay, theWeek);
       
   488 				aDays.AppendL(dayOfMonth);
       
   489 				}
       
   490 			}
       
   491 		}
       
   492 	}
       
   493 	
       
   494 /** Sets all dates of the month on which this rule is repeated.
       
   495 
       
   496 @leave KErrNotSupported If it is not a monthly repeat rule.
       
   497 
       
   498 @param aMonthDays Array containing all month dates that are to be set. Any month dates
       
   499 not included in this array will not be set. Any out of range dates will be ignored. 
       
   500 @publishedAll
       
   501 @released
       
   502 @capability None
       
   503 */
       
   504 EXPORT_C void TCalRRule::SetByMonthDay(const RArray<TInt>& aMonthDays)
       
   505 	{
       
   506 	__ASSERT_ALWAYS(iType == EMonthly, User::Leave(KErrNotSupported));
       
   507 	
       
   508 	iBuffer = 0;
       
   509 	TInt daysCount = aMonthDays.Count();
       
   510 	for (TInt i = 0; i < daysCount; ++i)
       
   511 		{
       
   512 		TInt bit = aMonthDays[i];
       
   513 		
       
   514 		// check this date is valid
       
   515 		if (bit >= 0 && bit <= 30)
       
   516 			{
       
   517 			SetNthBit(bit);
       
   518 			}
       
   519 		}
       
   520 	}
       
   521 
       
   522 /** Gets all dates of the month on which this rule is repeated.
       
   523 
       
   524 @param aMonthDays On return, this array contains all month dates that are to be set.
       
   525 This function will do nothing if this is not a monthly repeat rule. 
       
   526 Note that 0 represents 1st of the month, 1 represents 2nd, etc.
       
   527 @publishedAll
       
   528 @released 
       
   529 @capability None
       
   530 */
       
   531 EXPORT_C void TCalRRule::GetByMonthDayL(RArray<TInt>& aMonthDays) const
       
   532 	{
       
   533 	if (iType == EMonthly)
       
   534 		{
       
   535 		aMonthDays.Reset();
       
   536 		if (!GetNthBit(KMonthlyByWeek))
       
   537 			{			
       
   538 			// check first 31 bits of iBuffer to see which dates have been set
       
   539 			for (TInt i = 0; i <= 30; ++i)
       
   540 				{
       
   541 				if (GetNthBit(i))
       
   542 					{
       
   543 					aMonthDays.AppendL(i);
       
   544 					}
       
   545 				}
       
   546 			}
       
   547 		}
       
   548 	}
       
   549 
       
   550 /** Sets the month of the year for this repeat rule.
       
   551 
       
   552 @leave KErrNotSupported If it is not on a yearly repeat rule 
       
   553 @param aMonths Array of months on which to repeat. Only the first month in the array is used.
       
   554 @publishedAll
       
   555 @released
       
   556 @capability None
       
   557 */
       
   558 EXPORT_C void TCalRRule::SetByMonth(const RArray<TMonth> aMonths)
       
   559 	{
       
   560 	__ASSERT_ALWAYS(iType == EYearly, User::Leave(KErrNotSupported));
       
   561 	
       
   562 	if (aMonths.Count() >= 1)
       
   563 		{
       
   564 		TMonth month = aMonths[0];
       
   565 		if (month >= EJanuary && month <= EDecember)
       
   566 			{
       
   567 			if (!GetNthBit(KYearlyByWeek))
       
   568 				{
       
   569 				iBuffer = 0;
       
   570 				SetNthBit(KYearlyByWeek);
       
   571 				}
       
   572 			
       
   573 			TUint8* bufferPtr = (TUint8*)&iBuffer; // convert the iBuffer store to three TUint8s
       
   574 			// EJanuary=0 so store it as 1, this allows us to tell if any months have been set
       
   575 			bufferPtr[2] = (TUint8)month+1;
       
   576 			}
       
   577 		}
       
   578 	}
       
   579 
       
   580 /** Gets the month of the year for this repeat rule.
       
   581 This function will do nothing if this is not a yearly repeat rule
       
   582 @param aMonths On return, the months on which to repeat.
       
   583 @publishedAll
       
   584 @released 
       
   585 @capability None
       
   586 */
       
   587 EXPORT_C void TCalRRule::GetByMonthL(RArray<TMonth>& aMonths) const
       
   588 	{
       
   589 	if (iType == EYearly)
       
   590 		{
       
   591 		aMonths.Reset();
       
   592 		if (GetNthBit(KYearlyByWeek))
       
   593 			{
       
   594 			TUint8* bufferPtr = (TUint8*)&iBuffer; // convert the iBuffer store to three TUint8s
       
   595 			TMonth theMonth = TMonth(bufferPtr[2]-1); // -1 because EJanuary stored as 1
       
   596 			if (theMonth >= EJanuary && theMonth <= EDecember)
       
   597 				{
       
   598 				aMonths.AppendL(theMonth);
       
   599 				}
       
   600 			}
       
   601 		}
       
   602 	}
       
   603 
       
   604 /** Sets the first day of the week for this repeat rule.
       
   605 
       
   606 @param aDay The weekday to be the first. Any invalid parameter will be ignored. 
       
   607 @publishedAll
       
   608 @released
       
   609 @capability None
       
   610 */
       
   611 EXPORT_C void TCalRRule::SetWkSt(TDay aDay)
       
   612 	{
       
   613 	if (aDay >= EMonday && aDay <= ESunday)
       
   614 		{
       
   615 		iWkSt = aDay;
       
   616 		}
       
   617 	}
       
   618 	
       
   619 /** Gets the first day of the week for this repeat rule.
       
   620 
       
   621 @return The weekday to be the first.
       
   622 @publishedAll
       
   623 @released 
       
   624 @capability None
       
   625 */
       
   626 EXPORT_C TDay TCalRRule::WkSt() const
       
   627 	{
       
   628 	return iWkSt;
       
   629 	}
       
   630 
       
   631 void TCalRRule::SetUntilAndCount(const TCalTime& aTime, TUint aCount)
       
   632 	{
       
   633 	iUntil = aTime;
       
   634 	iCount = aCount;
       
   635 	}