diff --git a/JetHerald/Controllers/Ui/DashboardController.cs b/JetHerald/Controllers/Ui/DashboardController.cs index 51d7f5c..74fe93f 100644 --- a/JetHerald/Controllers/Ui/DashboardController.cs +++ b/JetHerald/Controllers/Ui/DashboardController.cs @@ -28,12 +28,34 @@ public class DashboardController : Controller var vm = new DashboardViewModel { Topics = topics.ToArray(), - Hearts = hearts.ToLookup(h => h.TopicId) + Hearts = hearts.Where(h => h.ExpiryTs + TimeSpan.FromDays(90) >= DateTime.UtcNow ).ToLookup(h => h.TopicId) }; return View(vm); } } + +public static class DateTimeExt +{ + public static string GetReadableDate(DateTime dt, DateTime now) + { + dt = dt.Date; + now = now.Date; + var daysDiff = (int)Math.Round((dt - now).TotalDays); + + if (daysDiff == 0) + return "today"; + if (daysDiff == 1) + return "tomorrow"; + if (daysDiff == -1) + return "yesterday"; + + if (Math.Abs(daysDiff) < 62) + return dt.ToString("MMM dd"); + return dt.ToString("yyyy MMMM dd"); + } +} + public class DashboardViewModel { public Topic[] Topics { get; set; } diff --git a/JetHerald/Views/Dashboard/Index.cshtml b/JetHerald/Views/Dashboard/Index.cshtml index 604336b..e99da28 100644 --- a/JetHerald/Views/Dashboard/Index.cshtml +++ b/JetHerald/Views/Dashboard/Index.cshtml @@ -1,17 +1,19 @@ @model DashboardViewModel @Html.ValidationSummary(false, "", new {}) - Create new topic + Create new topic