示例#1
0
        public string GetFormattedNoteTime(Note note)
        {
            if (note.GetType() == typeof(DeadlinedNote))
            {
                DeadlinedNote newNote = (DeadlinedNote)note;
                return("deadline " + newNote.Deadline.ToShortDateString());
            }
            else
            {
                bool isYesterday = DateTime.Today - note.Time.Date == TimeSpan.FromDays(1);
                bool isToday     = DateTime.Today - note.Time.Date == TimeSpan.FromDays(0);

                string result = "";
                if (isToday == true)
                {
                    result += note.Time.ToShortTimeString();
                }
                else if (isYesterday == true)
                {
                    result += "yesterday " + note.Time.ToShortTimeString();
                }
                else
                {
                    result += note.Time.ToShortDateString();
                }
                return(result);
            }
        }
示例#2
0
 public void CreateNote(string topic, string text, bool isImportant, DateTime deadline)
 {
     Console.WriteLine("created note with deadline param");
     if (deadline == null || deadline < DateTime.Now)
     {
         DefaultNote note = (DefaultNote)defaultNoteCreator.Create(topic, text, isImportant, deadline);
         Current.Insert(0, note);
         //visitor
         note.SetDetailInfo(new DetailInfoVisitor());
     }
     else
     {
         DeadlinedNote note = (DeadlinedNote)deadlinedNoteCreator.Create(topic, text, isImportant, deadline);
         Current.Insert(0, note);
         //visitor
         note.SetDetailInfo(new DetailInfoVisitor());
     }
 }
示例#3
0
 public string VisitDeadlinedNote(DeadlinedNote note)
 {
     return("created: " + note.Time.ToShortDateString() + " deadline: " + note.Deadline.ToShortDateString());
 }