Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve

## Unreleased

### Fixed

- Keep `--auto-close today` valid throughout the final second of the local
day, rather than expiring at the instant that second begins.

## [0.12.1] — 2026-09-12

### Added
Expand Down
5 changes: 4 additions & 1 deletion cmd/shell/autoclose.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,22 @@ func parseAbsoluteDeadline(value string, now time.Time) (time.Time, bool) {
// the last minute, so that the form still works during 23:59.
clock := "00:00"
second := 0
nanosecond := 0
if prefix == "today" {
clock = "23:59"
second = 59
nanosecond = int(time.Second - time.Nanosecond)
}
if len(value) > len(prefix) {
clock = strings.TrimSpace(value[len(prefix):])
second = 0
nanosecond = 0
}
parsedClock, err := time.ParseInLocation("15:04", clock, now.Location())
if err != nil {
return time.Time{}, false
}
return time.Date(day.Year(), day.Month(), day.Day(), parsedClock.Hour(), parsedClock.Minute(), second, 0, now.Location()), true
return time.Date(day.Year(), day.Month(), day.Day(), parsedClock.Hour(), parsedClock.Minute(), second, nanosecond, now.Location()), true
}
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/shell/autoclose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestParseCloseDeadline(t *testing.T) {
{name: "in prefix", value: "in 15m", want: now.Add(15 * time.Minute)},
{name: "tomorrow", value: "tomorrow 09:15", want: time.Date(2026, time.August, 20, 9, 15, 0, 0, location)},
{name: "bare tomorrow", value: "tomorrow", want: time.Date(2026, time.August, 20, 0, 0, 0, 0, location)},
{name: "bare today", value: "today", want: time.Date(2026, time.August, 19, 23, 59, 59, 0, location)},
{name: "bare today", value: "today", want: time.Date(2026, time.August, 19, 23, 59, 59, int(time.Second-time.Nanosecond), location)},
{name: "today with clock", value: "today 23:50", want: time.Date(2026, time.August, 19, 23, 50, 0, 0, location)},
{name: "clock rolls forward", value: "22:00", want: time.Date(2026, time.August, 20, 22, 0, 0, 0, location)},
{name: "local date", value: "2026-08-21 12:30", want: time.Date(2026, time.August, 21, 12, 30, 0, 0, location)},
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestNormalizeAutoCloseArgumentsRejectsMissingAndInvalidValues(t *testing.T)
func TestBareTodayIsADeadlineAllDay(t *testing.T) {
location := time.FixedZone("test", 2*60*60)
for _, clock := range []struct{ hour, minute, second int }{
{0, 0, 0}, {9, 15, 0}, {23, 58, 0}, {23, 59, 30},
{0, 0, 0}, {9, 15, 0}, {23, 58, 0}, {23, 59, 30}, {23, 59, 59},
} {
now := time.Date(2026, time.August, 19, clock.hour, clock.minute, clock.second, 0, location)
deadline, err := parseCloseDeadline("today", now)
Expand Down
Loading