|
//Intially setting the recurrence rule, start date and end date to the appointment
RecurrenceProperties recurrenceProperties = new RecurrenceProperties();
recurrenceProperties.RecurrenceType = RecurrenceType.Weekly;
recurrenceProperties.WeeklyEveryNWeeks = 1;
recurrenceProperties.IsWeeklyThursday = true;
recurrenceProperties.IsRangeRecurrenceCount = true;
recurrenceProperties.RangeRecurrenceCount = 10;
recurrenceProperties.RecurrenceRule = DependencyService.Get<IRecurrenceBuilder>().RRuleGenerator(recurrenceProperties, meeting.StartTime, meeting.EndTime);
appointment.RecurrenceRule = recurrenceProperties.RecurrenceRule;
appointment.StartTime = new DateTime(2018, 05, 24, 10, 0, 0);
appointment.EndTime = meeting.StartTime.AddHours(2);
|
|
//Dynamically changing the recurrence rule, start date and end date to the appointment
void Button_Clicked(object sender, EventArgs e)
{
RecurrenceProperties recurrenceProperties = new RecurrenceProperties();
recurrenceProperties.RecurrenceType = RecurrenceType.Weekly;
recurrenceProperties.WeeklyEveryNWeeks = 1;
recurrenceProperties.IsWeeklyMonday = true;
recurrenceProperties.IsRangeRecurrenceCount = true;
recurrenceProperties.RangeRecurrenceCount = 10;
recurrenceProperties.RecurrenceRule = DependencyService.Get<IRecurrenceBuilder>().RRuleGenerator(recurrenceProperties, meeting.StartTime, meeting.EndTime);
appointment.RecurrenceRule = recurrenceProperties.RecurrenceRule;
appointment.StartTime = new DateTime(2018, 05, 22, 10, 0, 0);
appointment.EndTime = meeting.StartTime.AddHours(2);
}
|
Hey there,
Thanks for your answer and I understand I need to always set the BYDAY.
As for the Timezone issue, let me see if I can resume this:
Assuming that I store the RecurrenceRule, StartTime and EndTime in my DB and assuming that my stored rule is 'FREQ=WEEKLY; INTERVAL=1;BYDAY=MO,WE;COUNT=10' then to show the appointment correctly for a certain Timezone I should:
1. Get the ByDay value (MO, WE) from my rule
2. Determine if the appoint StartTime occurs on a different day in my devices timeZone (either +1 day or -1 day)
3. Change the BYDAY rule according to point 2. (ex if I find my time zone is 12h behind and on the day before then BYDAY becomes 'SU,TU')
So the rule I need to generate now is FREQ=WEEKLY; INTERVAL=1;BYDAY=SU,TU;COUNT=10'
Would you say that is correct?
Let me see if I can test this and I will let you know.
Thanks,
Bernard