mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
33 lines
800 B
C#
33 lines
800 B
C#
using System.Collections.Generic;
|
|
using Hangfire;
|
|
|
|
namespace API.Helpers.Converters;
|
|
#nullable enable
|
|
|
|
public static class CronConverter
|
|
{
|
|
public static readonly IEnumerable<string> Options = new []
|
|
{
|
|
"disabled",
|
|
"daily",
|
|
"weekly",
|
|
};
|
|
/// <summary>
|
|
/// Converts to Cron Notation
|
|
/// </summary>
|
|
/// <param name="source">Defaults to daily</param>
|
|
/// <returns></returns>
|
|
public static string ConvertToCronNotation(string? source)
|
|
{
|
|
if (string.IsNullOrEmpty(source)) return Cron.Daily();
|
|
return source.ToLower() switch
|
|
{
|
|
"daily" => Cron.Daily(),
|
|
"weekly" => Cron.Weekly(),
|
|
"disabled" => Cron.Never(),
|
|
"" => Cron.Never(),
|
|
_ => source
|
|
};
|
|
}
|
|
}
|