diff --git a/README.md b/README.md index 97d6575..e1e077c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Before you begin, ensure you have the following installed: TO_EMAIL=recipient@example.com (optional) NTFY_AUTH=echo "Basic $(echo -n 'testuser:fakepassword' | base64)" NTFY_HOST=https://ntfy.sh/alerts + LOCATION=Europe/Berlin (default) ICS_DIR=/path/to/ics/files ``` diff --git a/main.go b/main.go index abbe25a..6dfbb89 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ var ( TO_EMAIL string NTFY_AUTH string NTFY_HOST string + LOCATION string ) func main() { @@ -28,6 +29,13 @@ func main() { TO_EMAIL = os.Getenv("TO_EMAIL") NTFY_AUTH = os.Getenv("NTFY_AUTH") NTFY_HOST = os.Getenv("NTFY_HOST") + LOCATION = os.Getenv("LOCATION") + + // Überprüfen, ob die Umgebungsvariable leer ist + if LOCATION == "" { + // Setzen Sie einen Standardwert, wenn die Umgebungsvariable leer ist + LOCATION = "Europe/Berlin" + } // Get the current working directory dir, err := os.Getwd() @@ -44,7 +52,7 @@ func main() { folders := strings.Split(folderList, ",") for _, folder := range folders { - log.Infof("folder: %s to: %s password: %s host: %s", folder, TO_EMAIL, NTFY_AUTH, NTFY_HOST) + log.Infof("folder: %s to: %s password: %s host: %s location: %s", folder, TO_EMAIL, NTFY_AUTH, NTFY_HOST, LOCATION) listFilesForFolder(folder) } } @@ -86,7 +94,7 @@ func getNotifications(file string) { } defer f.Close() - tz, _ := time.LoadLocation("Europe/Berlin") + tz, _ := time.LoadLocation(LOCATION) start, end := truncateToDay(time.Now(), tz), truncateToDay(time.Now(), tz).Add(24*60*time.Minute)