Skip to content

Commit

Permalink
Merge pull request #1139 from cogentcore/time-picker-test
Browse files Browse the repository at this point in the history
Add time input tests and improve docs
  • Loading branch information
rcoreilly authored Aug 15, 2024
2 parents 630c82d + 0bf355e commit b059000
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
30 changes: 30 additions & 0 deletions core/timepicker_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2024, Cogent Core. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package core

import (
"testing"
"time"
)

var testTime = time.Date(2021, 1, 4, 11, 16, 0, 0, time.UTC)

func TestTimeInput(t *testing.T) {
b := NewBody()
NewTimeInput(b).SetTime(testTime)
b.AssertRender(t, "time-input/basic")
}

func TestTimeInputDate(t *testing.T) {
b := NewBody()
NewTimeInput(b).SetTime(testTime).SetDisplayTime(false)
b.AssertRender(t, "time-input/date")
}

func TestTimeInputTime(t *testing.T) {
b := NewBody()
NewTimeInput(b).SetTime(testTime).SetDisplayDate(false)
b.AssertRender(t, "time-input/time")
}
6 changes: 6 additions & 0 deletions docs/content/2-widgets/4-pickers/time-pickers.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ You can create a unified time input that allows users to select both a date and
core.NewTimeInput(b).SetTime(time.Now())
```

You can hide the date or time part of a unified time input:

```Go
core.NewTimeInput(b).SetTime(time.Now()).SetDisplayDate(false)
```

You can detect when the user changes the value of a unified time input:

```Go
Expand Down

0 comments on commit b059000

Please sign in to comment.