Created the DropdownComponent.jsx utils

This commit is contained in:
Mathias Wagner
2022-08-31 01:12:43 +02:00
parent 6d4ca4189b
commit 69f5bea01b
@@ -0,0 +1,19 @@
import {parseExpression} from "cron-parser";
// Parses cron as a locale string
export const parseCron = (cron) => {
try {
return parseExpression(cron).next().toDate().toLocaleString()
} catch (e) {
return <span className="icon-orange">Eingabe ungültig</span>;
}
}
// Fixes the cron provided by the user
export const stringifyCron = (cron) => {
try {
return parseExpression(cron).stringify();
} catch (e) {
return null;
}
}