TimePicker

The TimePicker element extends the View interface and is intended for entering time.

To create a TimePicker, the function is used:

func NewTimePicker(session Session, params Params) TimePicker

You can set/get the current value using the "time-picker-value" property (TimePickerValue constant).The following can be passed as a value to the "time-picker-value" property:

  • time.Time
  • constant
  • text that can be converted to time.Time by function

func time.Parse(layout string, value string) (time.Time, error)

The text is converted to time.Time. Accordingly, the Get function always returns a time.Time value.The value of the "time-picker-value" property can also be read using the function:

func GetTimePickerValue(view View, subviewID ...string) time.Time

The time entered may be subject to restrictions. For this, the following properties are used:

Property Constant Data type Restriction
"time-picker-min" TimePickerMin time.Time Minimum time value
"time-picker-max" TimePickerMax time.Time The maximum value of time
"time-picker-step" TimePickerStep int Time step in seconds

You can read the values of these properties using the functions:

func GetTimePickerMin(view View, subviewID ...string) (time.Time, bool)
func GetTimePickerMax(view View, subviewID ...string) (time.Time, bool)
func GetTimePickerStep(view View, subviewID ...string) int

The "time-changed" event (TimeChangedEvent constant) is used to track the change in the entered value.The main event listener has the following format:

func(picker TimePicker, newTime, oldTime time.Time)

where the second argument is the new time value, the third argument is the previous time value.

Additional event listeners can have the following format

func(picker TimePicker, newTime time.Time)
func(newTime, oldTime time.Time)
func(newTime time.Time)
func(picker TimePicker)
func()

You can get the current list of date change listeners using the function

func GetTimeChangedListeners(view View, subviewID ...string) []func(TimePicker, time.Time, time.Time)