我正在使用ical.NET库解析一些在线ical日历并将其预览到我的Web应用程序中。
例如:
airBnbCalendar = client.DownloadData(Constants.Constants.airbnbGoldAptCalendarUri);
Stream stream = new MemoryStream(airBnbCalendar);
airBnbCal = Ical.Net.Calendar.Load(stream);
foreach (var item in airBnbCal.Events.Where(m => m.End.Date >= DateTime.Now))
{
resposneCalendarModel.Add(new ResponseCalendarModel
{
CheckInDateTime = item.Start.Date,
//I want CheckOutDateTime to substract one day before based on CheckOutDateTime
CheckOutDateTime = item.End.Date - item.End.Date.AddDays(-1),
// with these item.End.AddDays(-1)
//I am getting an error: Cannot implicitly convert type 'System.TimeSpan' to 'System.DateTime'
Duration = item.Duration.Days
});
}
如何将其转换为TimeSpan?
这是正确的做法吗?
CheckOutDateTime = item.End.Date - new TimeSpan(1, 0, 0, 0)