Skip to content

Commit

Permalink
fix(Dashboard): Fix DateTime format
Browse files Browse the repository at this point in the history
Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
  • Loading branch information
cdavernas committed Oct 14, 2024
1 parent a820544 commit 57eb3c2
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public static class DateTimeExtensions
/// <returns>The <see cref="DateTimeOffset"/>, formatted in a relative fashion</returns>
public static string RelativeFormat(this DateTimeOffset dateTime)
{
var localDateTime = dateTime.ToLocalTime();
var now = DateTimeOffset.Now;
var delta = now.Subtract(dateTime);
var delta = now.Subtract(localDateTime);
if (Math.Abs(delta.Days) >= 1)
{
var cultureFormats = CultureInfo.GetCultureInfo("en-US").DateTimeFormat;
Expand All @@ -44,9 +45,9 @@ public static string RelativeFormat(this DateTimeOffset dateTime)
defaults.LastWeek,
$"{cultureFormats.ShortDatePattern} {cultureFormats.ShortTimePattern}"
);
return now.DateTime.CalendarTime(dateTime.DateTime, formats);
return now.DateTime.CalendarTime(localDateTime.DateTime, formats);
}
else if (delta < TimeSpan.Zero) return dateTime.DateTime.ToNow();
else return dateTime.DateTime.FromNow();
else if (delta < TimeSpan.Zero) return localDateTime.DateTime.ToNow();
else return localDateTime.DateTime.FromNow();
}
}

0 comments on commit 57eb3c2

Please sign in to comment.