DateTimePicker
DateTimePicker create a datetimepicker and return its selected datetime.
API
func DateTimePicker(c *tgframe.Container, label string, conf ...*DateTimePickerConf) *time.Time
cis Parent container.labelis the label for datetimepicker.confis an optional configuration, at most one.- Return the selected datetime. nil if no datetime is selected.
// DateTimePickerConf is the configuration for the DateTimePicker component.
type DateTimePickerConf struct {
tgframe.Base // ID
// Default is the datetime the picker starts on, read to the minute. It is
// only read until the app user first picks one.
Default *time.Time
// Disabled is true if the datetimepicker is disabled.
Disabled bool
}
func (c *DateTimePickerConf) SetDefault(v time.Time) *DateTimePickerConf
Example
datetimeValue := tgcomp.DateTimePicker(p.Main, "DateTimePicker")
val := ""
if datetimeValue != nil {
val = datetimeValue.Format("2006-01-02 15:04")
}
tgcomp.Text(p.Main, "Value: "+val,
&tgcomp.TextConf{ID: "datetimepicker_result"})
Starting on a datetime, until the app user picks another:
tgcomp.DateTimePicker(p.Main, "DateTimePicker",
(&tgcomp.DateTimePickerConf{}).SetDefault(
time.Date(2026, 9, 8, 13, 5, 0, 0, time.UTC)))
The wire carries minutes, so a Default with seconds on it is read to the
minute — the same value a pick of that minute gives.
