2025-06-16 15:48:55 +08:00

26 lines
502 B
Go

package component
import (
"time"
"github.com/a-h/templ"
)
func YearBegin() templ.Component {
dt := time.Now()
t := dt.AddDate(0, -int(dt.Month())+1, -dt.Day()+1)
return templ.Raw(t.Format("2006-01-02") + " 00:00:00")
}
func MonthBegin() string {
dt := time.Now()
t := dt.AddDate(0, 0, -dt.Day()+1)
return t.Format("2006-01-02") + " 00:00:00"
}
func MonthEnd() string {
dt := time.Now()
t := dt.AddDate(0, 0, -dt.Day()+1).AddDate(0, 1, -1)
return t.Format("2006-01-02") + " 23:59:59"
}