refactor: move parsing into internal/parse module, move other functions into misc

This commit is contained in:
2025-08-01 16:39:03 -05:00
parent 378bc29e7e
commit 55a390e69c
8 changed files with 44 additions and 33 deletions

26
internal/misc.go Normal file
View File

@@ -0,0 +1,26 @@
package internal
import (
"reflect"
"runtime"
"sync/atomic"
)
type EnabledDisabledInfo struct {
Entity string
State string
RunOnError bool
}
var (
id atomic.Int64 // default value is 0
)
func GetId() int64 {
return id.Add(1)
}
// GetFunctionName returns the name of the function that the interface is a pointer to.
func GetFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}

View File

@@ -1,30 +1,13 @@
package internal
package parse
import (
"fmt"
"log/slog"
"reflect"
"runtime"
"sync/atomic"
"time"
"github.com/golang-module/carbon"
)
type EnabledDisabledInfo struct {
Entity string
State string
RunOnError bool
}
var (
id atomic.Int64 // default value is 0
)
func GetId() int64 {
return id.Add(1)
}
// Parses a HH:MM string.
func ParseTime(s string) carbon.Carbon {
t, err := time.Parse("15:04", s)
@@ -45,7 +28,3 @@ func ParseDuration(s string) time.Duration {
}
return d
}
func GetFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}