mirror of
https://github.com/tiennm99/ghglance.git
synced 2026-10-14 02:16:01 +00:00
Two cuts together keep the productive-time and productive-weekday
titles at the same 15 px the rest of the gallery uses:
1. utcOffsetLabel is now compact. Integer offsets drop the '.00'
padding ("UTC+7" vs the old "UTC+7.00") and non-integer offsets use
the colon form ("UTC+5:30", "UTC+5:45"). Saves 3 chars for the
common integer case, so "Commits by Hour (last year, UTC+7)" lands
at 34 chars — inside the 15 px budget.
2. weekdayTitle no longer embeds the UTC label. Day-of-week aggregates
by whole days; clock precision isn't informative there, and
dropping it shortens the title to 30 chars so the full 15 px lands
for every timezone.
Quarter-hour-zone users (Kathmandu UTC+5:45) see the hour title drop
to 14 px — 37 chars still exceeds the budget — but that's a rare
case and only 1 px off.
TestUTCOffsetLabel updated to the new format. TestFitTitleFontSize
pinned the new titles.
32 lines
785 B
Go
32 lines
785 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// TestUTCOffsetLabel checks the compact format: integer hours drop the
|
|
// minutes suffix, non-zero offsets render as `UTC±H:MM`.
|
|
func TestUTCOffsetLabel(t *testing.T) {
|
|
cases := []struct {
|
|
zone string
|
|
want string // must appear in the label; exact value varies by DST
|
|
}{
|
|
{"UTC", "UTC+0"},
|
|
{"Asia/Saigon", "UTC+7"},
|
|
{"Asia/Kolkata", "UTC+5:30"}, // half-hour zone
|
|
{"Asia/Kathmandu", "UTC+5:45"}, // quarter-hour zone
|
|
}
|
|
for _, tc := range cases {
|
|
loc, err := time.LoadLocation(tc.zone)
|
|
if err != nil {
|
|
t.Skipf("%s unavailable: %v", tc.zone, err)
|
|
}
|
|
got := utcOffsetLabel(loc)
|
|
if !strings.Contains(got, tc.want) {
|
|
t.Errorf("utcOffsetLabel(%q) = %q, want prefix %q", tc.zone, got, tc.want)
|
|
}
|
|
}
|
|
}
|