split daily schedule and interval

This commit is contained in:
Sam Lewis
2022-11-13 20:17:00 -05:00
parent 83998b5e7e
commit ced79559e5
7 changed files with 275 additions and 136 deletions

View File

@@ -3,6 +3,8 @@ package internal
import (
"fmt"
"log"
"reflect"
"runtime"
"time"
"github.com/golang-module/carbon"
@@ -15,12 +17,13 @@ func GetId() int64 {
return id
}
// Parses a HH:MM string.
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.", s)
}
return carbon.Now().StartOfDay().SetHour(t.Hour()).SetMinute(t.Minute())
return carbon.Now().SetTimeMilli(t.Hour(), t.Minute(), 0, 0)
}
func ParseDuration(s string) time.Duration {
@@ -30,3 +33,7 @@ func ParseDuration(s string) time.Duration {
}
return d
}
func GetFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}