prime8dev

prime8dev
git clone https://git.prime8.dev/prime8dev.git
Log | Files | Refs | README | LICENSE

uptime_test.go (601B)


      1 package utils
      2 
      3 import (
      4 	"testing"
      5 	"time"
      6 )
      7 
      8 func TestUptimeUsesBirthZone(t *testing.T) {
      9 	la, err := time.LoadLocation("America/Chicago")
     10 	if err != nil {
     11 		t.Skip(err)
     12 	}
     13 	birth := time.Date(2008, time.April, 20, 0, 0, 0, 0, la)
     14 	// 22:30 CDT Oct 22 is already Oct 23 in UTC; must still read 185d.
     15 	now := time.Date(2026, time.October, 23, 3, 30, 0, 0, time.UTC)
     16 	if got := Uptime(birth, now); got != "18y 185d" {
     17 		t.Fatalf("got %q, want 18y 185d", got)
     18 	}
     19 	if got := Uptime(birth, time.Date(2026, time.April, 20, 6, 0, 0, 0, time.UTC)); got != "18y 0d" {
     20 		t.Fatalf("birthday: got %q", got)
     21 	}
     22 }