Kavita/API/Helpers/Converters/CronConverter.cs
2022-02-07 05:30:28 -08:00

30 lines
736 B
C#

using System.Collections.Generic;
using Hangfire;
namespace API.Helpers.Converters
{
public static class CronConverter
{
public static readonly IEnumerable<string> Options = new []
{
"disabled",
"daily",
"weekly",
};
public static string ConvertToCronNotation(string source)
{
var destination = string.Empty;
destination = source.ToLower() switch
{
"daily" => Cron.Daily(),
"weekly" => Cron.Weekly(),
"disabled" => Cron.Never(),
"" => Cron.Never(),
_ => destination
};
return destination;
}
}
}