Esempio n. 1
0
 private static TimeSpan?ConvertReminder(Library.Generic.TodoTask task, Library.Generic.Reminder reminder)
 {
     return
         (task.DueDate.HasValue
             ? reminder?.Date.Subtract(task.DueDate.Value)
             : null);
 }
Esempio n. 2
0
        private static Repeat ConvertRepeat(Library.Generic.TodoTask task)
        {
            if (task.RecurrenceType == null)
            {
                return(null);
            }

            return(new Repeat
            {
                RepeatCount = task.RecurrenceCount,
                RepeatType = Convert(task.RecurrenceType.Value)
            });
        }
Esempio n. 3
0
        private static Priority ConvertPriority(Library.Generic.TodoTask task)
        {
            switch (task.Starred.Total)
            {
            case 1:
                return(Priority.None);

            case 2:
                return(task.Starred.Level == 0? Priority.None : Priority.High);

            default:
                throw new ArgumentOutOfRangeException(nameof(task), "Cannot convert priorities with " + task.Starred.Level +
                                                      " levels to TickTick priorities.");
            }
        }
Esempio n. 4
0
 private static TodoTask Convert(
     Library.Generic.TodoTask task)
 {
     return(new TodoTask
     {
         FolderName = "",
         ListName = task.List.Title,
         Title = task.Title,
         Tags = string.Join(", ", task.Tags),
         Content = Content(task),
         IsCheckList = task.Subtasks.Any(),
         StartDate = null,
         DueDate = task.DueDate,
         Reminder = ConvertReminder(task, task.Reminder),
         Repeat = ConvertRepeat(task),
         Priority = ConvertPriority(task),
         Status = task.Completed ? Status.Completed : Status.Pending,
         CreatedTime = null,
         CompletedTime = task.CompletedAt,
         Order = 0,
         TimeZone = "UTC",
         IsAllDay = true,
     });
 }
Esempio n. 5
0
 private static string Content(Library.Generic.TodoTask task)
 {
     return(task.Note?.Content + string.Join("\r\n",
                                             task.Subtasks?.Select(x => x.Completed ? "▪" + x.Title : "▫" + x.Title) ?? new string[0]));
 }