mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-31 20:24:27 -04:00
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using Hangfire;
|
|
|
|
namespace API.Helpers.Converters
|
|
{
|
|
public static class CronConverter
|
|
{
|
|
// TODO: this isn't used. Replace strings with Enums?
|
|
public static readonly IEnumerable<string> Options = new []
|
|
{
|
|
"disabled",
|
|
"daily",
|
|
"weekly",
|
|
};
|
|
public static string ConvertToCronNotation(string source)
|
|
{
|
|
string destination = "";
|
|
destination = source.ToLower() switch
|
|
{
|
|
"daily" => Cron.Daily(),
|
|
"weekly" => Cron.Weekly(),
|
|
"disabled" => Cron.Never(),
|
|
"" => Cron.Never(),
|
|
_ => destination
|
|
};
|
|
|
|
return destination;
|
|
}
|
|
|
|
public static string ConvertFromCronNotation(string cronNotation)
|
|
{
|
|
string destination = "";
|
|
destination = cronNotation.ToLower() switch
|
|
{
|
|
"0 0 31 2 *" => "disabled",
|
|
_ => destination
|
|
};
|
|
|
|
return destination;
|
|
}
|
|
}
|
|
} |