コード例 #1
0
        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()));
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
 public FeedDTO(Feed feed)
 {
     Id          = feed.Id;
     Title       = feed.Title;
     Author      = feed.Author;
     Link        = feed.Link;
     Description = feed.Description;
     PublishedAt = feed.PublishedAt;
     UrlToImage  = feed.UrlToImage;
     Source      = new SourceDTO(feed.Source);
     ReadCount   = feed.ReadCount;
     TimeAgo     = RelativeDateParser.ConvertToTimeAgo(feed.PublishedAt.Value);
 }