refactor(ui): dedupe FormatRemaining between UsagePill and UsageMonitorModal
Both viewmodels carried byte-identical copies of the reset-countdown formatter. Moved it to UsageTimeFormat.FormatRemaining and pointed both call sites at it; locale keys and output unchanged.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using ClaudeDo.Ui.Localization;
|
||||
|
||||
namespace ClaudeDo.Ui.Services;
|
||||
|
||||
/// <summary>Shared "Xh Ym" formatting for usage-reset countdowns (pill tooltip + usage monitor gauges).</summary>
|
||||
public static class UsageTimeFormat
|
||||
{
|
||||
public static string FormatRemaining(DateTimeOffset resetsAt)
|
||||
{
|
||||
var remaining = resetsAt - DateTimeOffset.UtcNow;
|
||||
if (remaining < TimeSpan.Zero) remaining = TimeSpan.Zero;
|
||||
var hours = (int)remaining.TotalHours;
|
||||
var minutes = remaining.Minutes;
|
||||
return hours > 0
|
||||
? Loc.T("usage.pill.durationHoursMinutes", hours, minutes)
|
||||
: Loc.T("usage.pill.durationMinutes", minutes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user