Exemple #1
0
		public SEvent ToEvent(IEvent evnt, bool isRecurrenceRuleOnly = false)
		{
			if (evnt == null || evnt.UID.IsNullOrEmpty())
				return null;

			if (evnt.Start == null) evnt.Start = new iCalDateTime(_now);
			if (evnt.End == null) evnt.End = evnt.Start;

			if (evnt.LastModified == null) evnt.LastModified = new iCalDateTime(_now);

			var cEvent = new SEvent();
			cEvent.Event = evnt;
			cEvent.Sequence = evnt.Sequence;
			cEvent.Id = evnt.UID;
			cEvent.FeedId = GetQualifiedFeedId(evnt.UID, FeedIdBase);
			cEvent.Title = evnt.Summary;
			cEvent.Description = evnt.Description;
			cEvent.LocationDescription = evnt.Location;
			cEvent.TimeZone = _currentTZ == null ? null : _currentTZ.TZId();
			cEvent.IsAllDay = evnt.IsAllDay;

			bool hasTime = false;
			bool hasStartTime = false;
			bool hasEndTime = false;
			if (!isRecurrenceRuleOnly) {

				cEvent.Start = GetLocalTime(evnt.Start, _currentTZ, out hasStartTime);
				cEvent.End = GetLocalTime(evnt.End, _currentTZ, out hasEndTime);
				cEvent.RecurrenceId = GetLocalTime(evnt.RecurrenceID, _currentTZ, out hasTime);
			}
			cEvent.Updated = SetUpdatedEventTimeToStartTime 
				? cEvent.Start.DateTime 
				: evnt.LastModified.Value; //.ToDateTime(cEvent.Start.DateTime);
			
			if (!cEvent.IsAllDay && !hasStartTime && !hasEndTime)
				cEvent.IsAllDay = true;

			cEvent.Url = evnt.Url == null ? null : evnt.Url.OriginalString;

			var loc = evnt.GeographicLocation;
			if (loc != null && loc.Latitude != 0) {
				cEvent.Latitude = (decimal)loc.Latitude;
				cEvent.Longitude = (decimal)loc.Longitude;
			}
			return cEvent;
		}
Exemple #2
0
		public SEvent Copy(string idAppendValue = null)
		{
			var c = new SEvent();

			c.Id = Id + idAppendValue; // order matters, as FeedId may use ItemId, ExtUrl, etc
			c.FeedId = FeedId + idAppendValue;
			c.Title = Title;
			c.Start = Start;
			c.End = End;
			c.RecurrenceId = RecurrenceId;
			c.IsAllDay = IsAllDay;
			c.TimeZone = TimeZone;
			c.Updated = Updated;
			c.Description = Description;
			c.RRuleStr = RRuleStr;
			c.Url = Url;
			c.ImageUrl = ImageUrl;
			c.Longitude = Longitude;
			c.Latitude = Latitude;
			c.LocationDescription = LocationDescription;
			c.Address = Address;
			c.IsHomeLocation = IsHomeLocation;

			return c;
		}