mirror of
https://github.com/Xevion/go-ha.git
synced 2026-01-31 06:24:27 -06:00
listeners working, sunrise/sunset working with string offset
This commit is contained in:
@@ -1,8 +1,23 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/golang-module/carbon"
|
||||
)
|
||||
|
||||
var id int64 = 0
|
||||
|
||||
func GetId() int64 {
|
||||
id += 1
|
||||
return id
|
||||
}
|
||||
|
||||
func ParseTime[T ~string](s T) carbon.Carbon {
|
||||
t, err := time.Parse("15:04", string(s))
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse time string \"%s\"; format must be HH:MM.", s)
|
||||
}
|
||||
return carbon.Now().StartOfDay().SetHour(t.Hour()).SetMinute(t.Minute())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user