TimePicker

An element which is used for selecting and inputting specific time of a day

Create from source

func NewTimePicker(session Session, params Params) TimePicker

Create new time picker object and returns its interface

Create from resource

TimePicker {
    id = timePicker,
    time-picker-max = "15:00:00",
    time-picker-min = "10:00:00",
    time-picker-value = "09:52:36",
}

Interface description

Inherit methods, properties and events from View

Properties

"data-list"

An array of recommended values. The value of this property must be an array of strings in the format "HH:MM:SS" or "HH:MM"

Constant: DataList

Types: []string, string, []fmt.Stringer, []Color, []SizeUnit, []AngleUnit, []any containing elements of string, fmt.Stringer, bool, rune, float32, float64, int, int8int64, uint, uint8uint64

Internal type is []string, other types converted to it during assignment

Conversion rules

string - contain single item

[]string - an array of items

[]fmt.Stringer - an array of objects convertible to a string

[]Color - An array of color values which will be converted to a string array

[]SizeUnit - an array of size unit values which will be converted to a string array

[]any - this array must contain only types which were listed in Types section

Examples

TimePicker {
    data-list = [
        "08:00:00",
        "08:15:00"
    ]
}
picker := rui.NewTimePicker(session, rui.Params{
    rui.DataList: []string{
        "08:00:00",
        "08:15:00",
    },
})

"max"

Same as "time-picker-max"

Constant: Max

"min"

Same as "time-picker-min"

Constant: Min

"step"

Same as "time-picker-step"

Constant: Step

"time-picker-max"

The maximum value of the time

Constant: TimePickerMax

Types: time.Time, string

Internal type is time.Time, other types converted to it during assignment

Conversion rules

string - values of this type parsed and converted to time.Time. The following formats are supported:

Format Example
"HH:MM:SS" "08:15:00"
"HH:MM:SS PM" "08:15:00 AM"
"HH:MM" "08:15"
"HH:MM PM" "08:15 AM"

Examples

TimePicker {
    time-picker-max = "15:00:00",
}
picker := rui.NewTimePicker(session, rui.Params{
    rui.TimePickerMax: "15:00:00",
})
t, err := time.Parse("11:12:13", "15:00:00")
if err != nil {
    fmt.Println(err)
    return
}

picker = rui.NewTimePicker(session, rui.Params{
    rui.TimePickerMax: t,
})

"time-picker-min"

The minimum value of the time

Constant: TimePickerMin

Types: time.Time, string

Internal type is time.Time, other types converted to it during assignment

Conversion rules

string - values of this type parsed and converted to time.Time. The following formats are supported:

Format Example
"HH:MM:SS" "08:15:00"
"HH:MM:SS PM" "08:15:00 AM"
"HH:MM" "08:15"
"HH:MM PM" "08:15 AM"

Examples

TimePicker {
    time-picker-min = "08:00:00",
}
picker := rui.NewTimePicker(session, rui.Params{
    rui.TimePickerMin: "08:00:00",
})
t, err := time.Parse("11:12:13", "08:00:00")
if err != nil {
    fmt.Println(err)
    return
}

picker = rui.NewTimePicker(session, rui.Params{
    rui.TimePickerMin: t,
})

"time-picker-step"

Time step in seconds

Constant: TimePickerStep

Types: int, string

Values

int string Description
>= 0 >= "0" Step value in seconds used to increment or decrement time

"time-picker-value"

Current value

Constant: TimePickerValue

Types: time.Time, string

Internal type is time.Time, other types converted to it during assignment

Conversion rules

string - values of this type parsed and converted to time.Time. The following formats are supported:

Format Example
"HH:MM:SS" "08:15:00"
"HH:MM:SS PM" "08:15:00 AM"
"HH:MM" "08:15"
"HH:MM PM" "08:15 AM"

Examples

TimePicker {
    time-picker-value = "08:00:00",
}
picker := rui.NewTimePicker(session, rui.Params{
    rui.TimePickerValue: "08:00:00",
})
t, err := time.Parse("11:12:13", "08:00:00")
if err != nil {
    fmt.Println(err)
    return
}

picker = rui.NewTimePicker(session, rui.Params{
    rui.TimePickerValue: t,
})

"value"

Same as "time-picker-value"

Constant: Value

Events

"time-changed"

Occur when current time of the time picker has been changed

Constant: TimeChangedEvent

General listener format:

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

where: * picker - Interface of a time picker which generated this event * newTime - New time value * oldTime - Old time value

Allowed listener formats:

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

func(newTime, oldTime time.Time)

func(newTime time.Time)

func(picker rui.TimePicker)

func()

func GetDataList(view View, subviewID ...string) []string

Returns the data list of an editor. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.

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

Returns the TimeChangedListener list of TimePicker subview. If there are no listeners then the empty list is returned If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

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

Returns the max time of TimePicker subview and "true" as the second value if the min time is set, "false" as the second value otherwise. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

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

Returns the min time of TimePicker subview and "true" as the second value if the min time is set, "false" as the second value otherwise. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTimePickerStep(view View, subviewID ...string) int

Returns the time changing step in seconds of TimePicker subview. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

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

Returns the time of TimePicker subview. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func TimePickerByID(rootView View, id string) TimePicker

Return a TimePicker with id equal to the argument of the function or nil if there is no such View or View is not TimePicker