schedule next run part 2
All checks were successful
ci / build (push) Successful in 1m6s

This commit is contained in:
Christopher Hase 2025-03-28 13:21:30 +01:00
parent cf719e90ac
commit 68b996535d

View file

@ -37,6 +37,8 @@ exec('iching divine', (error, stdout, stderr) => {
if (config == undefined) {
config = loadConfig();
} else { //TODO: JUST FOR DEBUGGING
console.log(`Config already read...`);
}
console.log(config.daysInterval, config.timeOfDay);
@ -53,11 +55,13 @@ exec('iching divine', (error, stdout, stderr) => {
// Funktion, um die Konfiguration zu laden
function loadConfig(): Config {
console.log(`Load Config`);
const data = fs.readFileSync('config.json', 'utf-8');
return JSON.parse(data);
}
// Send E-Mail
async function sendEmail(content: string) {
try {
@ -89,7 +93,7 @@ async function sleep() {
function calculateNextRunDate(daysInterval: number, timeOfDay: string): Date {
const currentDate = new Date();
// Splitte die Uhrzeit in Stunden und Minuten
/*// Splitte die Uhrzeit in Stunden und Minuten
const [hours, minutes] = timeOfDay.split(':').map(Number);
// Berechne das Datum für die nächste Ausführung
@ -103,6 +107,10 @@ function calculateNextRunDate(daysInterval: number, timeOfDay: string): Date {
// Berechne das Datum für den nächsten Ausführungszeitpunkt unter Berücksichtigung von X Tagen
currentDate.setDate(currentDate.getDate() + daysInterval);
return currentDate;*/
currentDate.setMinutes(currentDate.getMinutes() + 1); //TODO: JUST FOR DEBUGGING!!!
return currentDate;
}