Jürgen Eckel f68d0df98b
* avoid using app.Logger to have a consistent log from the beginning
* made lazyLoading local to the module
* fixed ticker bug so that the tasks are executed in an endless loop
* fixed timezone bug of Add Participant. only validator local time is used not the timestamp from the mqtt messages as these might come from a different time zone (resulted in delayed deletion from the activeActors DB)
* improved connection management for the monitor
* added a watchdog task to restart the monitor in case of connection loss (every 2 min)

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2024-05-15 11:12:59 +02:00

26 lines
713 B
Go

package util
import (
"log"
"strconv"
"time"
)
func String2UnixTime(timeInput string) (int64, error) {
// Layout specifying the format of the input string
// Note: Go uses a specific reference time (Mon Jan 2 15:04:05 MST 2006) to define format layouts
layout := "2006-01-02T15:04:05"
log.Println("[app] [Monitor] [time] add time string: " + timeInput)
// Parse the string into a time.Time struct in local time zone
parsedTime, err := time.Parse(layout, timeInput)
if err != nil {
return 0, err
}
// Convert to UTC if not already
utcTime := parsedTime.UTC()
unixTime := utcTime.Unix()
log.Println("[app] [Monitor] [time] unix time: " + strconv.FormatInt(unixTime, 10))
return unixTime, nil
}