DatePicker

An element which is designed to allow to input dates. "date-picker-value" property is used to get or set current date value

Create from source

func NewDatePicker(session Session, params Params) DatePicker

Create new date picker object and returns its interface

Create from resource

DatePicker {
    id = datePicker,
}

Interface description

Inherit methods, properties and events from View

Properties

"data-list"

List of predefined dates. If we set this property, date picker may have a drop-down menu with a list of these values. Some browsers may ignore this property, such as Safari for macOS. The value of this property must be an array of strings in the format "YYYY-MM-DD"

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

DatePicker {
    data-list = [
        2024-08-12,
        2024-12-31,
    ],
}
picker := rui.NewDatePicker(session, rui.Params{
    rui.DataList: []string{
        "2024-08-12",
        "2024-12-31",
    },
})

"date-picker-max"

Maximum date value

Constant: DatePickerMax

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
"YYYYMMDD" "20240102"
"Mon-DD-YYYY" "Jan-02-24"
"Mon-DD-YY" "Jan-02-2024"
"DD-Mon-YYYY" "02-Jan-2024"
"YYYY-MM-DD" "2024-01-02"
"Month DD, YYYY" "January 02, 2024"
"DD Month YYYY" "02 January 2024"
"MM/DD/YYYY" "01/02/2024"
"MM/DD/YY" "01/02/24"
"MMDDYY" "010224"

Examples

DatePicker {
    date-picker-max = "2024-08-31",
}
picker := rui.NewDatePicker(session, rui.Params{
    rui.DatePickerMax: "2024-08-31",
})
picker := rui.NewDatePicker(session, rui.Params{
    rui.DatePickerMin: time.Date(
        2024, time.August, 31, 0, 0, 0, 0, time.UTC
    ),
})

"date-picker-min"

Minimum date value

Constant: DatePickerMin

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
"YYYYMMDD" "20240102"
"Mon-DD-YYYY" "Jan-02-24"
"Mon-DD-YY" "Jan-02-2024"
"DD-Mon-YYYY" "02-Jan-2024"
"YYYY-MM-DD" "2024-01-02"
"Month DD, YYYY" "January 02, 2024"
"DD Month YYYY" "02 January 2024"
"MM/DD/YYYY" "01/02/2024"
"MM/DD/YY" "01/02/24"
"MMDDYY" "010224"

Examples

DatePicker {
    date-picker-min = "2024-08-01",
}
picker := rui.NewDatePicker(session, rui.Params{
    rui.DatePickerMin: "2024-08-01",
})
picker := rui.NewDatePicker(session, rui.Params{
    rui.DatePickerMin: time.Date(
        2024, time.August, 1, 0, 0, 0, 0, time.UTC
    ),
})

"date-picker-step"

Date change step in days

Constant: DatePickerStep

Types: int, string

Values

int string Description
>= 0 >= "0" Step value in days used to increment or decrement date

Examples

DatePicker {
    date-picker-step = 1,
}
picker := rui.NewDatePicker(session, rui.Params{
    rui.DatePickerStep: 1,
})

"date-picker-value"

Current value

Constant: DatePickerValue

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
"YYYYMMDD" "20240102"
"Mon-DD-YYYY" "Jan-02-24"
"Mon-DD-YY" "Jan-02-2024"
"DD-Mon-YYYY" "02-Jan-2024"
"YYYY-MM-DD" "2024-01-02"
"Month DD, YYYY" "January 02, 2024"
"DD Month YYYY" "02 January 2024"
"MM/DD/YYYY" "01/02/2024"
"MM/DD/YY" "01/02/24"
"MMDDYY" "010224"

Examples

DatePicker {
    date-picker-value = "2024-08-01",
}
picker := rui.NewDatePicker(session, rui.Params{
    rui.DatePickerValue: "2024-08-01",
})
picker := rui.NewDatePicker(session, rui.Params{
    rui.DatePickerValue: time.Date(
        2024, time.August, 1, 0, 0, 0, 0, time.UTC
    ),
})

"max"

Same as "date-picker-max"

Constant: Max

"min"

Same as "date-picker-min"

Constant: Min

"step"

Same as "date-picker-step"

Constant: Step

"value"

Same as "date-picker-value"

Constant: Value

Events

"date-changed"

Occur when date picker value has been changed

Constant: DateChangedEvent

General listener format:

func(picker rui.DatePicker, newDate, oldDate time.Time)

where: * picker - Interface of a date picker which generated this event * newDate - New date value * oldDate - Old date value

Allowed listener formats:

func(picker rui.DatePicker, newDate time.Time)

func(newDate, oldDate time.Time)

func(newDate time.Time)

func(picker rui.DatePicker)

func()

func DatePickerByID(rootView View, id string) DatePicker

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

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 GetDateChangedListeners(view View, subviewID ...string) []func(DatePicker, time.Time, time.Time)

Returns the DateChangedListener list of a DatePicker 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 GetDatePickerMax(view View, subviewID ...string) (time.Time, bool)

Returns the max date of DatePicker subview and "true" as the second value if the min date 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 GetDatePickerMin(view View, subviewID ...string) (time.Time, bool)

Returns the min date of DatePicker subview and "true" as the second value if the min date 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 GetDatePickerStep(view View, subviewID ...string) int

Returns the date changing step in days of DatePicker 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 GetDatePickerValue(view View, subviewID ...string) time.Time

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