package session import "time" // sessionTimeLayout is the fixed-width timestamp layout used for every stored // created_at/updated_at value. Unlike time.RFC3339Nano it never drops trailing // fractional zeros, so every value is exactly sessionTimeLen bytes wide. SQLite // compares these TEXT columns as plain strings, and equal width is what makes // that comparison agree with chronological order. Values are written in UTC, so // the Z07:00 zone renders as a single "Z". const sessionTimeLayout = "2006-01-02T15:04:05.000000000Z07:00" // sessionTimeLen is the byte length of a UTC value formatted with // sessionTimeLayout: "2006-01-02T15:04:05.000000000Z" — the Z07:00 zone // collapses to "Z" in UTC. const sessionTimeLen = 30 // formatSessionTime encodes t in UTC with the fixed-width sessionTimeLayout. func formatSessionTime(t time.Time) string { return t.UTC().Format(sessionTimeLayout) }