D-Day Calendar has wrong dates when importing from google calendar?

这一生的挚爱 提交于 2019-12-06 16:55:07

If it is an all day event, I believe the end time will be 00:00:00 on the next day, aka 12:00:00 AM. Is this not what you're seeing for the times?

The last example you give truly does span two days (March has 31 days), and is correct. The output you're seeing jives with the definition of an All Day Event. It begins at 12:00 AM and ends at 12:00 AM the next day.

If you wanted All Day events to truely stay only on the same day, you could do a check like:

if (((end - start) == TimeSpan.FromDays(1.0))
    && (start.Hour == 0 && start.Minute == 0))
{
    end = end - TimeSpan.FromSeconds(1.0); // now 23:59:59 same day as start
}

Chobo,

If you're trying to create all-day events in DDay.iCal it's really simple:

event.IsAllDay = true;

Is that what you're trying to accomplish? In all honesty your problem isn't all that clear from what you've already told us.

Thanks, -Doug

You need to set the same date for Start and End properties and IsAllDay = true:

var evt = iCal.Create<DDay.iCal.Event>();
evt.Start = new iCalDateTime(myEvent.Date);
evt.End = new iCalDateTime(myEvent.Date);
evt.IsAllDay = true;

Otherwise IsAllDay property doesn't work as expected. Please check implementation of this property:

 virtual public bool IsAllDay
        {
            get { return !Start.HasTime; }
            set
            {
                // Set whether or not the start date/time
                // has a time value.
                if (Start != null)
                    Start.HasTime = !value;
                if (End != null)
                    End.HasTime = !value;

                if (value && 
                    Start != null &&
                    End != null &&
                    object.Equals(Start.Date, End.Date))
                {
                    Duration = default(TimeSpan);
                    End = Start.AddDays(1);
                }
            }
        }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!