22 lines
357 B
Go
22 lines
357 B
Go
package service
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"fmt"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func mustJSON(v any) json.RawMessage {
|
||
|
|
b, err := json.Marshal(v)
|
||
|
|
if err != nil {
|
||
|
|
return json.RawMessage(`{}`)
|
||
|
|
}
|
||
|
|
return b
|
||
|
|
}
|
||
|
|
|
||
|
|
// ISOWeek returns the ISO-8601 week key like "2026-W37".
|
||
|
|
func ISOWeek(t time.Time) string {
|
||
|
|
year, week := t.ISOWeek()
|
||
|
|
return fmt.Sprintf("%d-W%02d", year, week)
|
||
|
|
}
|