Flow.Launcher/Flow.Launcher.Infrastructure/Storage/HistoryItem.cs
Shengkai Lin c51c029263
Some checks are pending
Build / build (push) Waiting to run
Merge branch 'dev' into avalonia_migration
Resolved conflicts:
- Calculator.csproj: Keep Mages 3.0.1 (from dev) + Avalonia packages
- Explorer SettingsViewModel.cs: Use PromptUserSelectFileAsync for ShellPath
- ExplorerSettings.xaml: Removed (deleted in HEAD)
- packages.lock.json: Restored from dev
2026-02-01 13:33:39 +08:00

46 lines
1.6 KiB
C#

using System;
namespace Flow.Launcher.Storage
{
[Obsolete("Use LastOpenedHistoryResult instead. This class will be removed in future versions.")]
public class HistoryItem
{
public string Query { get; set; }
public DateTime ExecutedDateTime { get; set; }
public string GetTimeAgo()
{
return DateTimeAgo(ExecutedDateTime);
}
private string DateTimeAgo(DateTime dt)
{
var span = DateTime.Now - dt;
if (span.Days > 365)
{
int years = (span.Days / 365);
if (span.Days % 365 != 0)
years += 1;
return $"about {years} {(years == 1 ? "year" : "years")} ago";
}
if (span.Days > 30)
{
int months = (span.Days / 30);
if (span.Days % 31 != 0)
months += 1;
return $"about {months} {(months == 1 ? "month" : "months")} ago";
}
if (span.Days > 0)
return $"about {span.Days} {(span.Days == 1 ? "day" : "days")} ago";
if (span.Hours > 0)
return $"about {span.Hours} {(span.Hours == 1 ? "hour" : "hours")} ago";
if (span.Minutes > 0)
return $"about {span.Minutes} {(span.Minutes == 1 ? "minute" : "minutes")} ago";
if (span.Seconds > 5)
return $"about {span.Seconds} seconds ago";
if (span.Seconds <= 5)
return "just now";
return string.Empty;
}
}
}