RezinaLMS-BackEnd/internal/domain/timezone_test.go
Yared Yemane d886cb68bc Make EAT the default app timezone for date filters.
Centralize Africa/Addis_Ababa and interpret YYYY-MM-DD query bounds in EAT instead of UTC.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-04 14:44:40 +03:00

31 lines
734 B
Go

package domain
import (
"testing"
"time"
)
func TestParseDateOnly_usesEAT(t *testing.T) {
got, err := ParseDateOnly("2026-08-01")
if err != nil {
t.Fatal(err)
}
want := time.Date(2026, time.August, 1, 0, 0, 0, 0, AppTimezone())
if !got.Equal(want) {
t.Fatalf("got %v want %v", got, want)
}
if got.UTC().Hour() != 21 {
t.Fatalf("EAT midnight should be 21:00 UTC previous day, got %v", got.UTC())
}
}
func TestDateOnly_truncatesInEAT(t *testing.T) {
// 2026-07-31 21:30 UTC = 2026-08-01 00:30 EAT
in := time.Date(2026, time.July, 31, 21, 30, 0, 0, time.UTC)
got := DateOnly(in)
want := time.Date(2026, time.August, 1, 0, 0, 0, 0, AppTimezone())
if !got.Equal(want) {
t.Fatalf("got %v want %v", got, want)
}
}