mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-04-24 01:59:29 -04:00
Co-authored-by: Joseph Milazzo <joseph.v.milazzo@gmail.com> Co-authored-by: Joe Milazzo <josephmajora@gmail.com>
32 lines
771 B
C#
32 lines
771 B
C#
using System.Collections.Generic;
|
|
using Hangfire;
|
|
|
|
namespace Kavita.Common.Helpers;
|
|
|
|
public static class CronConverter
|
|
{
|
|
public static readonly IEnumerable<string> Options =
|
|
[
|
|
"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
|
|
};
|
|
}
|
|
}
|