Skip to content
Snippets Groups Projects
Commit e20cd008 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Add HumanSince() wrapper method.

parent b5d91767
No related branches found
No related tags found
No related merge requests found
......@@ -331,13 +331,13 @@ namespace ATxCommon.Serializables
$"TransferInProgress: {TransferInProgress}\n" +
$"CurrentTransferSize: {CurrentTransferSize}\n" +
$"LastStatusUpdate: {LastStatusUpdate:yyyy-MM-dd HH:mm:ss}" +
$" ({TimeUtils.SecondsToHuman(TimeUtils.SecondsSince(LastStatusUpdate))})\n" +
$" ({TimeUtils.HumanSince(LastStatusUpdate)})\n" +
$"LastStorageNotification: {LastStorageNotification:yyyy-MM-dd HH:mm:ss}" +
$" ({TimeUtils.SecondsToHuman(TimeUtils.SecondsSince(LastStorageNotification))})\n" +
$" ({TimeUtils.HumanSince(LastStorageNotification)})\n" +
$"LastAdminNotification: {LastAdminNotification:yyyy-MM-dd HH:mm:ss}" +
$" ({TimeUtils.SecondsToHuman(TimeUtils.SecondsSince(LastAdminNotification))})\n" +
$" ({TimeUtils.HumanSince(LastAdminNotification)})\n" +
$"LastGraceNotification: {LastGraceNotification:yyyy-MM-dd HH:mm:ss}" +
$" ({TimeUtils.SecondsToHuman(TimeUtils.SecondsSince(LastGraceNotification))})\n";
$" ({TimeUtils.HumanSince(LastGraceNotification)})\n";
}
#endregion validate and report
......
......@@ -97,5 +97,14 @@ namespace ATxCommon
public static string DaysToHuman(long delta) {
return MinutesToHuman(delta * 60 * 24);
}
/// <summary>
/// Wrapper to convert a date into a human readable string relative to now.
/// </summary>
/// <param name="refDate">The reference DateTime to check.</param>
/// <returns>A string describing the delta, e.g. "12 days" or "3 weeks".</returns>
public static string HumanSince(DateTime refDate) {
return SecondsToHuman(SecondsSince(refDate));
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment