Neighbourhood.omg.lol/Models/Paste.cs
Gordon Pedersen a02b14782b Added in pastes (from people)
might still need some work/testing
Also, should I add pastes in the feed?
2024-07-23 17:02:53 +10:00

29 lines
1.1 KiB
C#

namespace Neighbourhood.omg.lol.Models {
public class Paste {
public string? Url;
public string Title { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public long? ModifiedOn { get; set; }
public int Listed { get; set; }
public bool IsListed {
get => Listed != 0;
set => Listed = value ? 1 : 0;
}
public DateTimeOffset ModifiedTime { get => DateTimeOffset.UnixEpoch.AddSeconds(ModifiedOn ?? 0); }
public string RelativeTime {
get {
TimeSpan offset = DateTimeOffset.UtcNow - ModifiedTime;
var offsetString = string.Empty;
if (offset.TotalDays >= 1) offsetString = $"{Math.Floor(offset.TotalDays)} days ago";
else if (offset.TotalHours >= 1) offsetString = $"{Math.Floor(offset.TotalHours)} hours, {offset.Minutes} minutes ago";
else if (offset.TotalMinutes >= 1) offsetString = $"{Math.Floor(offset.TotalMinutes)} minutes ago";
else offsetString = $"{Math.Floor(offset.TotalSeconds)} seconds ago";
return offsetString;
}
}
}
}