46acf3cba0
FormatRU printed a plan item's At raw. An event and a reminder come off the store as UTC — a calendar fact's Ts, a reminder's FireTs — while a checklist line is built in the asking clock's zone, so one spoken sentence named two zones. This is the voice path, so it is what he actually heard; the same defect on /morning and /events was V-612. Every hour is now read in the plan's own zone, Date's, which BuildPlan sets from the asking clock. The rest-of-day path in queryDayPlan rebuilds a plan off the wire, where nothing had put the instants in that frame, so it does now. formatTime is the same bug in the same daemon: "когда я это сделал?" names a fact's Ts, and the branch that prints a wall clock printed the store's. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
58 lines
2.1 KiB
Go
58 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// "когда я это сделал?" answers off a fact's Ts, which the store hands back as
|
|
// UTC, and the branch that names a wall clock printed it in whatever zone it
|
|
// arrived in (V-614). The instant here is built three hours off this machine's
|
|
// zone, so the assertion holds under TZ=UTC as well.
|
|
func TestFormatTimeReadsHisClock(t *testing.T) {
|
|
_, off := time.Now().Zone()
|
|
away := time.FixedZone("away", off+3*60*60)
|
|
stored := time.Now().Add(-72 * time.Hour).In(away)
|
|
|
|
got := formatTime(stored)
|
|
if want := stored.Local().Format("15:04"); !strings.Contains(got, want) {
|
|
t.Errorf("formatTime = %q, want the hour on his clock (%s)", got, want)
|
|
}
|
|
if bad := stored.Format("15:04"); strings.Contains(got, bad) {
|
|
t.Errorf("formatTime = %q reads the zone the fact arrived in (%s)", got, bad)
|
|
}
|
|
}
|
|
|
|
// TestMentionsUnknownDayReadsWordsNotStems — the defect V-581 found. The
|
|
// weekday half of this guard was a list of stems matched with strings.Contains,
|
|
// so "среди", "средство" and "средний" all read as Wednesday and the question
|
|
// was answered with onlyNearDaysReply instead of a date.
|
|
//
|
|
// The other half of the fix is coverage: a stem list stops at the forms whoever
|
|
// wrote it thought of, and "воскресеньях" was not one of them.
|
|
func TestMentionsUnknownDayReadsWordsNotStems(t *testing.T) {
|
|
for _, u := range []string{
|
|
"какое число в понедельник",
|
|
"какое число в среду",
|
|
"какое число в среде",
|
|
"что там по воскресеньям",
|
|
"what is the date on friday",
|
|
"какое число через неделю",
|
|
} {
|
|
if !mentionsUnknownDay(u) {
|
|
t.Errorf("mentionsUnknownDay(%q) = false, want true", u)
|
|
}
|
|
}
|
|
for _, u := range []string{
|
|
"какое число в среднем",
|
|
"сколько это в среднем",
|
|
"какое сегодня средство",
|
|
"какое число",
|
|
} {
|
|
if mentionsUnknownDay(u) {
|
|
t.Errorf("mentionsUnknownDay(%q) = true; it names no day", u)
|
|
}
|
|
}
|
|
}
|