diff --git a/core/timepicker_test.go b/core/timepicker_test.go new file mode 100644 index 0000000000..bff268e1d9 --- /dev/null +++ b/core/timepicker_test.go @@ -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") +} diff --git a/docs/content/2-widgets/4-pickers/time-pickers.md b/docs/content/2-widgets/4-pickers/time-pickers.md index b969eedc60..15a41cae3b 100644 --- a/docs/content/2-widgets/4-pickers/time-pickers.md +++ b/docs/content/2-widgets/4-pickers/time-pickers.md @@ -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