Skip to content

Commit

Permalink
Make DateTime friendlier (WalletWasabi#13237)
Browse files Browse the repository at this point in the history
* Make DateTime friendlier

* Use local time
  • Loading branch information
SuperJMN authored Aug 16, 2024
1 parent 360cbd3 commit 8c6318d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions WalletWasabi.Fluent/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ public static string ToUserFacingString(this DateTime value, bool withTime = tru

public static string ToUserFacingFriendlyString(this DateTime value)
{
var time = value.ToString("hh:mm");

if (value.Date == DateTime.Today)
{
return "Today";
return $"Today at {time}";
}

if (value.Date == DateTime.Today.AddDays(-1))
{
return "Yesterday";
return $"Yesterday at {time}";
}

return value.ToString("MMM d, yyyy");
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi.Fluent/Extensions/DateTimeOffsetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ namespace WalletWasabi.Fluent.Extensions;

public static class DateTimeOffsetExtensions
{
public static string ToUserFacingString(this DateTimeOffset value, bool withTime = true) => value.DateTime.ToUserFacingString(withTime);
public static string ToUserFacingString(this DateTimeOffset value, bool withTime = true) => value.LocalDateTime.ToUserFacingString(withTime);

public static string ToUserFacingFriendlyString(this DateTimeOffset value) => value.DateTime.ToUserFacingFriendlyString();
public static string ToUserFacingFriendlyString(this DateTimeOffset value) => value.LocalDateTime.ToUserFacingFriendlyString();

public static string ToOnlyTimeString(this DateTimeOffset value) => value.ToString("HH:mm");
}

0 comments on commit 8c6318d

Please sign in to comment.