private long GetHoursAgo(HackerNewsSubmission submission) { var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); var then = submission.Time; var sSince = now - then; var mSince = sSince / 60; var hSince = mSince / 60; return(hSince); }
public HackerNewsResult(int n, HackerNewsSubmission submission) : base(string.Format(BaseUrl, submission.Id)) { Title = n + ". " + submission.Title; Subtitle = submission.Score + " points by " + submission.Author + " " + GetHoursAgo(submission) + " hours ago | " + submission.Descendants + " comments"; // Will be null if no external link was submitted if (!string.IsNullOrEmpty(submission.Url)) { Title += " (" + GetBaseUrl(submission) + ")"; Options.Add(new UrlQueryResult("Open " + submission.Url, submission.Url)); } }
private string GetBaseUrl(HackerNewsSubmission submission) { var uri = new Uri(submission.Url); return(uri.Host); }