MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / TruncateToWeek

Function TruncateToWeek

internal/models/usage.go:62–71  ·  view source on GitHub ↗

TruncateToWeek truncates a time to the start of its week (Monday 00:00:00 UTC).

(t time.Time)

Source from the content-addressed store, hash-verified

60
61// TruncateToWeek truncates a time to the start of its week (Monday 00:00:00 UTC).
62func TruncateToWeek(t time.Time) time.Time {
63 t = t.UTC()
64 weekday := int(t.Weekday())
65 if weekday == 0 {
66 weekday = 7 // Sunday becomes 7
67 }
68 // Subtract days to get to Monday
69 monday := t.AddDate(0, 0, -(weekday - 1))
70 return time.Date(monday.Year(), monday.Month(), monday.Day(), 0, 0, 0, 0, time.UTC)
71}

Callers 2

trackWeeklyUsageMethod · 0.92

Calls

no outgoing calls

Tested by 1