0

I am using library ical.NET for parsing some online ical calendars and previewing into my webapp.

for example:

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
 });
}

How to convert it to TimeSpan?

Is this right thing to do:

CheckOutDateTime = item.End.Date - new TimeSpan(1, 0, 0, 0)
Stefan0309
  • 1,602
  • 5
  • 23
  • 61

0 Answers0