0

I'm trying to creat a calender event that will be an all day event and will repeat every year from a list that has everyone's birthday. The recurrence works great and so does the All day event.

The problem is when I set newBirthDay["All Day Event"] = 1; the recurrence all of a sudden doesn't put the event in the correct day, but in the next day.

So say your birthday is on the 8th month and 3rd day, it will actually show up on the calender on August 4th and this only happens when I try to make it an All Day Event. If I leave it as normal it will show up on the correct day August 3rd. Anyone have any idea what could cause this? the C# code is included that handles it.

Thanks for looking

newBirthDay = calList.Add();

            newBirthDay["Title"] = "Happy Birthday, " + addBirthday["Title"].ToString();
            newBirthDay["Entry Type"] = "Birthday";

            string recurrence = "<recurrence><rule>" +
                                "<firstDayOfWeek>su</firstDayOfWeek>" +
                                "<repeat><yearly yearFrequency='1' month='" + addBirthday["Month"].ToString() + 
                                                                "' day='" + addBirthday["Day"].ToString() + "'/></repeat>" +
                                "<repeatForever>FALSE</repeatForever>" +
                                "</rule></recurrence>";


            newBirthDay["RecurrenceData"] = recurrence;
            newBirthDay["EventType"] = 1;
            newBirthDay["All Day Event"] = 1;
            newBirthDay["Recurrence"] = 1;
            newBirthDay["EventDate"] = new DateTime(DateTime.Now.Year, int.Parse(addBirthday["Month"].ToString()), int.Parse(addBirthday["Day"].ToString()));
            newBirthDay["EndDate"] = new DateTime(DateTime.Now.AddYears(100).Year, int.Parse(addBirthday["Month"].ToString()), int.Parse(addBirthday["Day"].ToString()));                
            newBirthDay["UID"] = System.Guid.NewGuid();
            newBirthDay["Description"] = "Happy Birthday, " + addBirthday["Name1"].ToString() + "\nbrithday = " + int.Parse(addBirthday["Day"].ToString()) + "|" + addBirthday["Day"].ToString();

            newBirthDay.Update();

2 Answers 2

0

I had a colleague look at programmatically setting recurrence lately, I can't remember the details of his issue or how he resolved it but basically the "end time" for your events in the series should represent the end of the recurrence.

1
  • Thats not my issue, If you look at my EndDate I add 100 years to it so it'll repeat for 100 years. The only issue I have is when I enable All Day Event it puts it on the next day instead of the day set in EventDate in calendar view.
    – user1211
    Aug 4, 2010 at 12:21
0

Apprently if you set it to an All Day Event it stores the date in UTC time so depending on your timezone it could end up looking like the next day.

Just set newBirthDay["TimeZone"]= -8;

and now it shows up on the correct day in my calendar for my timezone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.