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:
2026-02-07 22:56:40 -07:00
parent bf06c000db
commit a458207ae9
5 changed files with 166 additions and 1045 deletions

View File

@@ -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}";
}
}