public void UpdateSyncData(GoogleTaskSyncData syncData, TaskSyncData syncDataSource) { syncData.GoogleTask.Title = syncDataSource.Subject; syncData.GoogleTask.Notes = syncDataSource.Body; if (syncDataSource.DueTime != null) { var dueTime = syncDataSource.DueTime.Value; var dueTimeUtcFormat = new DateTime(dueTime.Year, dueTime.Month, dueTime.Day, 0, 0, 0, DateTimeKind.Utc); syncData.GoogleTask.Due = Rfc3339DateTime.ToString(dueTimeUtcFormat); } else { syncData.GoogleTask.Due = null; } if (syncDataSource.IsCompleted) { syncData.GoogleTask.Status = "completed"; var currentDate = DateTime.Now.Date; var currentDateUtcFormat = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 0, 0, 0, DateTimeKind.Utc); syncData.GoogleTask.Completed = Rfc3339DateTime.ToString(currentDateUtcFormat); } else { syncData.GoogleTask.Status = "needsAction"; syncData.GoogleTask.Completed = null; } }
public GoogleCalendarEventSyncData CreateFrom(TaskSyncData syncDataSource) { var calendarEvent = new Event(); calendarEvent.Summary = syncDataSource.Subject; calendarEvent.Description = syncDataSource.Body; DateTime dueTime; if (syncDataSource.DueTime != null) { dueTime = syncDataSource.DueTime.Value; } else { dueTime = syncDataSource.CreateTime; } var currentDate = dueTime.Date; var startTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 0, 0, 0, DateTimeKind.Utc); var endTime = startTime.AddHours(1); string start = Rfc3339DateTime.ToString(startTime); string end = Rfc3339DateTime.ToString(endTime); calendarEvent.Start = new EventDateTime() { DateTime = start }; calendarEvent.End = new EventDateTime() { DateTime = end }; return(new GoogleCalendarEventSyncData(calendarEvent)); }
public GoogleTaskSyncData CreateFrom(TaskSyncData syncDataSource) { var task = new GoogleTask(); task.Title = syncDataSource.Subject; task.Notes = syncDataSource.Body; if (syncDataSource.DueTime != null) { var dueTime = syncDataSource.DueTime.Value; var dueTimeUtcFormat = new DateTime(dueTime.Year, dueTime.Month, dueTime.Day, 0, 0, 0, DateTimeKind.Utc); task.Due = Rfc3339DateTime.ToString(dueTimeUtcFormat); } if (syncDataSource.IsCompleted) { task.Status = "completed"; } else { task.Status = "needsAction"; } return(new GoogleTaskSyncData(task)); }