Add timestamp & edited to chatroom and also do the same stuff from 2nd last commit in here in edit popup
This commit is contained in:
@@ -107,4 +107,22 @@ public static class Tools
|
||||
|
||||
return (totalXp, flooredLevel, currentXpInLevel, totalXpForLevel, percentDone);
|
||||
}
|
||||
|
||||
public static string FormatHumanTime(long unixTimestamp)
|
||||
{
|
||||
DateTime date = DateTimeOffset.FromUnixTimeSeconds(unixTimestamp).LocalDateTime;
|
||||
DateTime now = DateTime.Now;
|
||||
|
||||
bool isToday = date.Year == now.Year && date.Month == now.Month && date.Day == now.Day;
|
||||
DateTime yesterday = now.AddDays(-1);
|
||||
bool isYesterday = date.Year == yesterday.Year && date.Month == yesterday.Month && date.Day == yesterday.Day;
|
||||
|
||||
string timeStr = date.ToString("t");
|
||||
|
||||
if (isToday) return timeStr;
|
||||
if (isYesterday) return $"Yesterday at {timeStr}";
|
||||
|
||||
string dateStr = date.ToShortDateString();
|
||||
return $"{dateStr}, {timeStr}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user