mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-08 04:07:18 -06:00
Added daily schedule test. Migrated relevant files to slog.
This commit is contained in:
@@ -2,7 +2,7 @@ package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"time"
|
||||
@@ -27,7 +27,7 @@ func GetId() int64 {
|
||||
func ParseTime(s string) carbon.Carbon {
|
||||
t, err := time.Parse("15:04", s)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse time string \"%s\"; format must be HH:MM.\n", s)
|
||||
slog.Error(fmt.Sprintf("Failed to parse time string \"%s\"; format must be HH:MM.\n", s))
|
||||
}
|
||||
return carbon.Now().SetTimeMilli(t.Hour(), t.Minute(), 0, 0)
|
||||
}
|
||||
@@ -35,7 +35,7 @@ func ParseTime(s string) carbon.Carbon {
|
||||
func ParseDuration(s string) time.Duration {
|
||||
d, err := time.ParseDuration(s)
|
||||
if err != nil {
|
||||
log.Fatalf(fmt.Sprintf("Couldn't parse string duration: \"%s\" see https://pkg.go.dev/time#ParseDuration for valid time units\n", s))
|
||||
slog.Error(fmt.Sprintf("Couldn't parse string duration: \"%s\" see https://pkg.go.dev/time#ParseDuration for valid time units\n", s))
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user