mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-19 13:14:21 +01:00
Improve time helper to also work with future datetimes
This commit is contained in:
committed by
Andrew Camilleri
parent
e42ef4b2f8
commit
fa83304697
@@ -63,7 +63,10 @@ namespace BTCPayServer.Abstractions.Extensions
|
||||
|
||||
public static string ToTimeAgo(this DateTimeOffset date)
|
||||
{
|
||||
var formatted = (DateTimeOffset.UtcNow - date).TimeString() + " ago";
|
||||
var diff = DateTimeOffset.UtcNow - date;
|
||||
var formatted = diff.Seconds > 0
|
||||
? $"{diff.TimeString()} ago"
|
||||
: $"in {diff.Negate().TimeString()}";
|
||||
return formatted;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user