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
8 changes: 3 additions & 5 deletions internal/tui/datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ func (p *dateTimePicker) handleKey(msg tea.KeyPressMsg) tea.Cmd {
}
}

// dateStep is the day-at-a-time keys. Both pairs are here because neither means anything
// else on a date field: the arrows are unbound in a single-line text input, and a + or a -
// cannot appear in YYYY-MM-DD, so typing one is only ever a step.
// dateStep is the day-at-a-time keys. The arrows are unbound in a single-line text input,
// and a + cannot appear in YYYY-MM-DD, so typing one is only ever a step. A - is the date's
// own separator, so it is typed into the field like any other character (hey-cli#368).
func dateStep(msg tea.KeyPressMsg) (days int, stepped bool) {
switch msg.Key().Code {
case tea.KeyUp:
Expand All @@ -268,8 +268,6 @@ func dateStep(msg tea.KeyPressMsg) (days int, stepped bool) {
switch msg.String() {
case "+", "=":
return 1, true
case "-":
return -1, true
}
return 0, false
}
Expand Down
11 changes: 11 additions & 0 deletions internal/tui/datetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ func TestDateTimePickerStepsTheDateByADay(t *testing.T) {
}
}

func TestDateTimePickerTypesTheDateSeparator(t *testing.T) {
picker := testPicker()
picker.focusFirst()
picker.dateInput.SetValue("2026-08")

typeInto(t, picker, "-22")
if got := picker.date(); got != "2026-08-22" {
t.Errorf("after typing -22, date() = %q, want 2026-08-22", got)
}
}

func TestDateTimePickerAllDayHidesTheTimeAndTheZone(t *testing.T) {
picker := testPicker()
picker.setZoneName("Europe/Zagreb")
Expand Down
Loading