mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 13:27:21 +00:00
39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using AIStudio.Tools.PluginSystem;
|
|
|
|
namespace AIStudio.Settings.DataModel;
|
|
|
|
public static class MailboxMaxAgeExtensions
|
|
{
|
|
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(MailboxMaxAgeExtensions).Namespace, nameof(MailboxMaxAgeExtensions));
|
|
|
|
/// <param name="maxAge">The period.</param>
|
|
extension(MailboxMaxAge maxAge)
|
|
{
|
|
public string GetName() => maxAge switch
|
|
{
|
|
MailboxMaxAge.LAST_3_MONTHS => TB("The last 3 months"),
|
|
MailboxMaxAge.LAST_6_MONTHS => TB("The last 6 months"),
|
|
MailboxMaxAge.LAST_12_MONTHS => TB("The last 12 months"),
|
|
MailboxMaxAge.LAST_24_MONTHS => TB("The last 24 months"),
|
|
MailboxMaxAge.ALL => TB("All mails"),
|
|
|
|
_ => TB("Unknown period"),
|
|
};
|
|
|
|
/// <summary>
|
|
/// The first day of the period, as the sync asks the server for it.
|
|
/// </summary>
|
|
/// <param name="now">The current time.</param>
|
|
/// <returns>The first day, or null when the period has no end.</returns>
|
|
public DateTimeOffset? GetReceivedSince(DateTimeOffset now) => maxAge switch
|
|
{
|
|
MailboxMaxAge.LAST_6_MONTHS => now.AddMonths(-6),
|
|
MailboxMaxAge.LAST_12_MONTHS => now.AddMonths(-12),
|
|
MailboxMaxAge.LAST_24_MONTHS => now.AddMonths(-24),
|
|
MailboxMaxAge.ALL => null,
|
|
|
|
// The shortest period also stands in for a value this version does not know, as it does in the settings:
|
|
_ => now.AddMonths(-3),
|
|
};
|
|
}
|
|
} |