mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 22:11:48 +01:00
Improve time helper to also work with future datetimes
This commit is contained in:
parent
e42ef4b2f8
commit
fa83304697
1 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue