LANCommander/LANCommander.Launcher/Extensions/DateTimeExtensions.cs
Pat Hartl 9ba9887eb1 Rename project files, namespaces, artifacts
Client has been renamed to launcher, and thus namespaces and artifact names had to change. The server project has also had some artifacts renamed in order to create a more clear separation of builds. This will break auto-updates before v0.9.0.
2024-08-04 17:53:19 -05:00

24 lines
766 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LANCommander.Launcher.Extensions
{
public static class DateTimeExtensions
{
public static string ToRelativeDate(this DateTime dateTime)
{
var today = DateTime.Today;
var yesterday = today.AddDays(-1);
if (dateTime.Day == today.Day && dateTime.Month == today.Month && dateTime.Year == today.Year)
return "Today";
else if (dateTime.Day == yesterday.Day && dateTime.Month == yesterday.Month && dateTime.Year == yesterday.Year)
return "Yesterday";
else
return dateTime.ToString("MMMM d");
}
}
}