From d7de93434108de2e9267d472eae83a50f6c30e18 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 10:52:57 +0000 Subject: [PATCH 1/2] Initial plan From ab3992884b23738cc5c468d655dd7d0ca02bf3ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 10:57:41 +0000 Subject: [PATCH 2/2] Add comprehensive unit tests for FridayOfWeek function Co-authored-by: WZ <719869+WZ@users.noreply.github.com> --- models_test.go | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/models_test.go b/models_test.go index 510b7bf..c77c067 100644 --- a/models_test.go +++ b/models_test.go @@ -21,3 +21,115 @@ func TestReportWeekRangeMondayCutoff(t *testing.T) { t.Fatalf("expected current week for Monday afternoon, got %s -> %s", from.Format("20060102"), to.Format("20060102")) } } + +func TestFridayOfWeek(t *testing.T) { + loc := time.FixedZone("UTC+0", 0) + + tests := []struct { + name string + monday time.Time + expected string + }{ + { + name: "basic monday to friday", + monday: time.Date(2026, 2, 9, 0, 0, 0, 0, loc), + expected: "20260213", // Feb 13, 2026 (Friday) + }, + { + name: "monday with time component", + monday: time.Date(2026, 2, 9, 14, 30, 45, 0, loc), + expected: "20260213", // Feb 13, 2026 (Friday) + }, + { + name: "year boundary - monday in december", + monday: time.Date(2025, 12, 29, 0, 0, 0, 0, loc), + expected: "20260102", // Jan 2, 2026 (Friday) + }, + { + name: "year boundary - monday in january", + monday: time.Date(2026, 1, 5, 0, 0, 0, 0, loc), + expected: "20260109", // Jan 9, 2026 (Friday) + }, + { + name: "month boundary", + monday: time.Date(2026, 2, 23, 0, 0, 0, 0, loc), + expected: "20260227", // Feb 27, 2026 (Friday) + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + friday := FridayOfWeek(tt.monday) + got := friday.Format("20060102") + if got != tt.expected { + t.Errorf("FridayOfWeek(%s) = %s, want %s", + tt.monday.Format("20060102 15:04:05"), got, tt.expected) + } + + // Verify it's actually a Friday + if friday.Weekday() != time.Friday { + t.Errorf("FridayOfWeek(%s) returned %s (weekday: %s), expected Friday", + tt.monday.Format("20060102"), friday.Format("20060102"), friday.Weekday()) + } + + // Verify time components are preserved + if friday.Hour() != tt.monday.Hour() || friday.Minute() != tt.monday.Minute() || friday.Second() != tt.monday.Second() { + t.Errorf("FridayOfWeek(%s) time component not preserved: got %02d:%02d:%02d, want %02d:%02d:%02d", + tt.monday.Format("20060102 15:04:05"), + friday.Hour(), friday.Minute(), friday.Second(), + tt.monday.Hour(), tt.monday.Minute(), tt.monday.Second()) + } + + // Verify location is preserved + if friday.Location() != tt.monday.Location() { + t.Errorf("FridayOfWeek(%s) location not preserved: got %v, want %v", + tt.monday.Format("20060102"), friday.Location(), tt.monday.Location()) + } + }) + } +} + +func TestFridayOfWeekWithDifferentTimezones(t *testing.T) { + utc := time.UTC + pst := time.FixedZone("PST", -8*3600) + jst := time.FixedZone("JST", 9*3600) + + tests := []struct { + name string + monday time.Time + expected string + }{ + { + name: "UTC timezone", + monday: time.Date(2026, 2, 9, 10, 0, 0, 0, utc), + expected: "20260213", + }, + { + name: "PST timezone", + monday: time.Date(2026, 2, 9, 10, 0, 0, 0, pst), + expected: "20260213", + }, + { + name: "JST timezone", + monday: time.Date(2026, 2, 9, 10, 0, 0, 0, jst), + expected: "20260213", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + friday := FridayOfWeek(tt.monday) + got := friday.Format("20060102") + if got != tt.expected { + t.Errorf("FridayOfWeek(%s) = %s, want %s", + tt.monday.Format("20060102 15:04:05 MST"), got, tt.expected) + } + + // Verify location is preserved + if friday.Location() != tt.monday.Location() { + t.Errorf("FridayOfWeek(%s) location not preserved: got %v, want %v", + tt.monday.Format("20060102 15:04:05 MST"), friday.Location(), tt.monday.Location()) + } + }) + } +}