public IEnumerable <string> Handle(string input, Match match, IListener listener) { var task = match.Groups[1].Value; var time = match.Groups[2].Value; var dateTime = RelativeDateParser.Parse(input); ScheduleTicker.Instance.AddTask(dateTime, task); yield return("I will remind you to {0} at {1}".Template(task, dateTime.ToString())); }
/// <summary> /// Parse a date/time string. /// /// If the relative time includes hours, minutes or seconds, it's relative to now, /// else it's relative to today. /// </summary> /// <param name="input"> /// - "-1 day": Yesterday /// - "+12 weeks": Today twelve weeks later /// - "1 seconds": One second later from now. /// - "5 days 1 hour ago" /// - "1 year 2 months 3 weeks 4 days 5 hours 6 minutes 7 seconds" /// - "today": This day at midnight. /// - "now": Right now (date and time). /// - "next week" /// - "last month" /// - "2010-12-31" /// - "01/01/2010 1:59 PM" /// - "23:59:58": Today at the given time. /// </param> public static DateTime str2time(string input) { RelativeDateParser r = new RelativeDateParser(); DateTime retorno; retorno = r.Parse(input); r = null; return(retorno); }