Documentation
¶
Overview ¶
Package datetime holds MujicaUI date and time pickers and calendar views.
Index ¶
- func AvailabilityPicker(c *ui.Context, mine *[][]bool, opts AvailabilityPickerOptions) core.ChoiceResult
- func CalendarFirstWeekday(c *ui.Context, w WeekStart) time.Weekday
- func CountdownText(c *ui.Context, d time.Duration, f CountdownFormat) string
- func CronEditor(c *ui.Context, expr *string, opts CronEditorOptions) core.ChoiceResult
- func CurrentTimeIndicator(c *ui.Context, opts CurrentTimeIndicatorOptions) ui.Element
- func DurationPicker(c *ui.Context, value *time.Duration, opts DurationPickerOptions) core.ChoiceResult
- func DurationText(c *ui.Context, v time.Duration) string
- func EventChip(c *ui.Context, ev CalendarEvent, opts EventChipOptions) ui.Element
- func EventTone(k theme.Tokens, c EventColor) ui.Color
- func RecurrenceSummary(c *ui.Context, r Recurrence) string
- func RelativeTime(c *ui.Context, t time.Time, opts RelativeTimeOptions) ui.Element
- func RelativeTimeText(c *ui.Context, d time.Duration) string
- func ReminderPicker(c *ui.Context, value *[]time.Duration, opts ReminderPickerOptions) core.ChoiceResult
- func ReminderText(c *ui.Context, d time.Duration) string
- func Stopwatch(c *ui.Context, s *StopwatchState, opts StopwatchOptions) core.ChoiceResult
- func StopwatchText(d time.Duration) string
- func TimezoneOffset(loc *time.Location, t time.Time) string
- func TimezoneSelect(c *ui.Context, zone *string, opts TimezoneSelectOptions) core.ChoiceResult
- func WeekPicker(c *ui.Context, value *core.Date, opts WeekPickerOptions) core.ChoiceResult
- func WeekViewTitle(c *ui.Context, a, b core.Date) string
- type AgendaViewOptions
- type Attendee
- type AttendeeListOptions
- type AttendeeListResult
- type AttendeeStatus
- type AvailabilityPerson
- type AvailabilityPickerOptions
- type CalendarChange
- type CalendarChangeKind
- type CalendarDayViewOptions
- type CalendarEvent
- type CalendarMonthViewOptions
- type CalendarOptions
- type CalendarViewResult
- func AgendaView(c *ui.Context, events []CalendarEvent, opts AgendaViewOptions) CalendarViewResult
- func CalendarDayView(c *ui.Context, day *core.Date, events []CalendarEvent, ...) CalendarViewResult
- func CalendarMonthView(c *ui.Context, month *YearMonth, events []CalendarEvent, ...) CalendarViewResult
- func CalendarWeekView(c *ui.Context, week *core.Date, events []CalendarEvent, ...) CalendarViewResult
- func YearView(c *ui.Context, year *int, events []CalendarEvent, opts YearViewOptions) CalendarViewResult
- type CalendarWeekViewOptions
- type CountdownFormat
- type CountdownOptions
- type CountdownResult
- type CronEditorOptions
- type CronError
- type CronProblem
- type CronRun
- type CronSchedule
- type CurrentTimeIndicatorOptions
- type DatePickerOptions
- type DateRange
- type DateRangePickerOptions
- type DateTimePickerOptions
- type DateTimeResult
- func Calendar(c *ui.Context, value *core.Date, opts CalendarOptions) DateTimeResult
- func DatePicker(c *ui.Context, value *core.Date, opts DatePickerOptions) DateTimeResult
- func DateRangePicker(c *ui.Context, value *DateRange, opts DateRangePickerOptions) DateTimeResult
- func DateTimePicker(c *ui.Context, value *time.Time, opts DateTimePickerOptions) DateTimeResult
- func MonthPicker(c *ui.Context, value *YearMonth, opts MonthPickerOptions) DateTimeResult
- func NewDateTimeResult(e, input ui.Element, changed, canceled bool) DateTimeResult
- func TimePicker(c *ui.Context, value *TimeOfDay, opts TimePickerOptions) DateTimeResult
- func TimeRangePicker(c *ui.Context, value *TimeRange, opts TimeRangePickerOptions) DateTimeResult
- func YearPicker(c *ui.Context, value *int, opts YearPickerOptions) DateTimeResult
- type DurationPickerOptions
- type EventChipOptions
- type EventColor
- type EventEditorOptions
- type EventEditorResult
- type EventPopoverOptions
- type EventPopoverResult
- type MonthPickerOptions
- type Recurrence
- type RecurrenceEditorOptions
- type RecurrenceResult
- type RelativeTimeOptions
- type ReminderPickerOptions
- type RepeatEnd
- type RepeatUnit
- type StopwatchOptions
- type StopwatchState
- type TimeOfDay
- type TimePickerOptions
- type TimeRange
- type TimeRangePickerOptions
- type TimezoneSelectOptions
- type WeekPickerOptions
- type WeekStart
- type YearMonth
- type YearPickerOptions
- type YearViewOptions
Examples ¶
- AgendaView
- AttendeeList
- AvailabilityPicker
- Calendar
- CalendarDayView
- CalendarMonthView
- CalendarWeekView
- Countdown
- CronEditor
- CurrentTimeIndicator
- DatePicker
- DateRangePicker
- DateTimePicker
- DurationPicker
- EventChip
- EventEditor
- EventPopover
- MonthPicker
- RecurrenceEditor
- RelativeTime
- ReminderPicker
- Stopwatch
- TimePicker
- TimeRangePicker
- TimezoneSelect
- WeekPicker
- YearPicker
- YearView
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AvailabilityPicker ¶
func AvailabilityPicker(c *ui.Context, mine *[][]bool, opts AvailabilityPickerOptions) core.ChoiceResult
AvailabilityPicker paints free slots and counts others' overlap.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
days := []core.Date{{Year: 2026, Month: time.October, Day: 12}, {Year: 2026, Month: time.October, Day: 13}}
mine := [][]bool{make([]bool, 18), make([]bool, 18)}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.AvailabilityPicker(c, &mine, datetime.AvailabilityPickerOptions{Days: days}).Changed() {
fmt.Println("availability changed")
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func CalendarFirstWeekday ¶
CalendarFirstWeekday resolves the first column for the window's locale.
func CountdownText ¶
CountdownText formats a non-negative duration in whole seconds.
func CronEditor ¶
func CronEditor(c *ui.Context, expr *string, opts CronEditorOptions) core.ChoiceResult
CronEditor edits, explains and previews a cron expression.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
expr := "0 9 * * MON-FRI"
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.CronEditor(c, &expr, datetime.CronEditorOptions{Location: time.Local}).Changed() {
if _, err := datetime.ParseCron(expr); err == nil {
fmt.Println("schedule", expr)
}
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func CurrentTimeIndicator ¶
func CurrentTimeIndicator(c *ui.Context, opts CurrentTimeIndicatorOptions) ui.Element
CurrentTimeIndicator rules the current time across its parent.
Example ¶
package main
import (
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
ui.Box(c).Size(200, 240).Children(func() {
datetime.CurrentTimeIndicator(c, datetime.CurrentTimeIndicatorOptions{Location: time.Local})
})
}
ui.Render(view, 400, 300, 1)
}
Output:
func DurationPicker ¶
func DurationPicker(c *ui.Context, value *time.Duration, opts DurationPickerOptions) core.ChoiceResult
DurationPicker edits hours, minutes and seconds within a range.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
length := 90 * time.Minute
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
opts := datetime.DurationPickerOptions{Min: 15 * time.Minute, Max: 8 * time.Hour}
if datetime.DurationPicker(c, &length, opts).Changed() {
fmt.Println("length", length)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func DurationText ¶
DurationText words a duration, as "1 h 30 min".
func EventChip ¶
func EventChip(c *ui.Context, ev CalendarEvent, opts EventChipOptions) ui.Element
EventChip is a clickable, truncating event block.
Example ¶
loc := time.Local
ev := exampleEvents(loc)[0]
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.EventChip(c, ev, datetime.EventChipOptions{Location: loc}).Clicked() {
fmt.Println("open", ev.ID)
}
}
ui.Render(view, 400, 300, 1)
func RecurrenceSummary ¶
func RecurrenceSummary(c *ui.Context, r Recurrence) string
RecurrenceSummary describes a rule in the window's language.
func RelativeTime ¶
RelativeTime shows t as "3 minutes ago", refreshing while shown.
Example ¶
package main
import (
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
posted := time.Date(2026, time.October, 5, 9, 0, 0, 0, time.Local)
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
datetime.RelativeTime(c, posted, datetime.RelativeTimeOptions{Location: time.Local})
}
ui.Render(view, 400, 300, 1)
}
Output:
func RelativeTimeText ¶
RelativeTimeText words d ago (positive) or ahead (negative).
func ReminderPicker ¶
func ReminderPicker(c *ui.Context, value *[]time.Duration, opts ReminderPickerOptions) core.ChoiceResult
ReminderPicker toggles reminder lead times, kept in choice order.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
reminders := []time.Duration{15 * time.Minute}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.ReminderPicker(c, &reminders, datetime.ReminderPickerOptions{Max: 3}).Changed() {
fmt.Println("reminders", reminders)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func ReminderText ¶
ReminderText words a lead time, as "15 minutes before".
func Stopwatch ¶
func Stopwatch(c *ui.Context, s *StopwatchState, opts StopwatchOptions) core.ChoiceResult
Stopwatch measures time with laps, ticking while running and shown.
Example ¶
package main
import (
"fmt"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
var sw datetime.StopwatchState
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.Stopwatch(c, &sw, datetime.StopwatchOptions{}).Changed() {
fmt.Println("laps", len(sw.Laps))
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func StopwatchText ¶
StopwatchText formats elapsed time as 01:02.3, with hours when needed.
func TimezoneOffset ¶
TimezoneOffset formats a zone's offset at t, as "UTC+09:00".
func TimezoneSelect ¶
func TimezoneSelect(c *ui.Context, zone *string, opts TimezoneSelectOptions) core.ChoiceResult
TimezoneSelect searches zones by name or offset into *zone.
Example ¶
package main
import (
"fmt"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
zone := "Asia/Shanghai"
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.TimezoneSelect(c, &zone, datetime.TimezoneSelectOptions{}).Changed() {
fmt.Println("zone", zone)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func WeekPicker ¶
func WeekPicker(c *ui.Context, value *core.Date, opts WeekPickerOptions) core.ChoiceResult
WeekPicker chooses a week; *value is its first day.
Example ¶
package main
import (
"fmt"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
var week core.Date
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.WeekPicker(c, &week, datetime.WeekPickerOptions{WeekStart: datetime.WeekStartMonday, Clearable: true}).Changed() {
fmt.Println("week of", week)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
Types ¶
type AgendaViewOptions ¶
type AgendaViewOptions struct {
// Location is the zone days are cut in; required.
Location *time.Location
// Version must change when events change in place.
Version int
// From is the first day listed; zero means today.
From core.Date
// Days is how many days are listed; zero means 30.
Days int
// Today is marked; zero uses the system clock.
Today core.Date
Hour12 bool
Disabled bool
Label string
}
AgendaViewOptions configure an AgendaView.
type Attendee ¶
type Attendee struct {
Name string
Email string
Status AttendeeStatus
Organizer bool
Optional bool
}
Attendee is one person invited to an event.
type AttendeeListOptions ¶
type AttendeeListOptions struct {
// Removable shows a remove button on everyone but the organizer.
Removable bool
Disabled bool
Label string
}
AttendeeListOptions configure an AttendeeList.
type AttendeeListResult ¶
AttendeeListResult is the list and the attendee the user removed.
func AttendeeList ¶
func AttendeeList(c *ui.Context, attendees []Attendee, opts AttendeeListOptions) AttendeeListResult
AttendeeList shows invitees, their replies and a summary.
Example ¶
package main
import (
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
people := []datetime.Attendee{{Name: "Sakiko", Status: datetime.AttendeeAccepted, Organizer: true}, {Name: "Mutsumi"}}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if i, ok := datetime.AttendeeList(c, people, datetime.AttendeeListOptions{Removable: true}).Removed(); ok {
people = append(people[:i], people[i+1:]...)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func (AttendeeListResult) Removed ¶
func (r AttendeeListResult) Removed() (int, bool)
Removed returns the index of the attendee the user removed.
type AttendeeStatus ¶
type AttendeeStatus int
AttendeeStatus is an attendee's reply.
const ( AttendeePending AttendeeStatus = iota AttendeeAccepted AttendeeTentative AttendeeDeclined )
type AvailabilityPerson ¶
AvailabilityPerson is another person's free slots, [day][slot].
type AvailabilityPickerOptions ¶
type AvailabilityPickerOptions struct {
// Days are the grid's columns; required.
Days []core.Date
// From and To are hours; zero means 9 to 18.
From, To int
// SlotMinutes must divide an hour; zero means 30.
SlotMinutes int
// Others are counted as free per slot.
Others []AvailabilityPerson
Hour12 bool
Disabled bool
Label string
}
AvailabilityPickerOptions configure an AvailabilityPicker.
type CalendarChange ¶
type CalendarChange struct {
Kind CalendarChangeKind
ID string
Start, End time.Time
AllDay bool
}
CalendarChange is a move, resize or creation to apply.
type CalendarChangeKind ¶
type CalendarChangeKind int
CalendarChangeKind says what a view gesture did.
const ( CalendarMove CalendarChangeKind = iota CalendarResize CalendarCreate )
type CalendarDayViewOptions ¶
type CalendarDayViewOptions struct {
// Location is the zone the day is cut in; required.
Location *time.Location
// Version must change when events change in place.
Version int
// SlotMinutes is the grid step; zero means 30.
SlotMinutes int
// Today is marked; zero uses the system clock.
Today core.Date
// Now places the current-time line; zero uses the system clock.
Now time.Time
Hour12 bool
Disabled bool
Label string
}
CalendarDayViewOptions configure a CalendarDayView.
type CalendarEvent ¶
type CalendarEvent struct {
ID string
Title string
Start time.Time
End time.Time
AllDay bool
Color EventColor
Location string
// Attendees, Reminders and Repeat are edited by EventEditor.
Attendees []Attendee
Reminders []time.Duration
Repeat Recurrence
}
CalendarEvent is one entry of the views; End is exclusive.
type CalendarMonthViewOptions ¶
type CalendarMonthViewOptions struct {
// Location is the zone days are cut in; required.
Location *time.Location
// Version must change when events change in place.
Version int
WeekStart WeekStart
// MaxPerDay is rows shown before "+N"; zero means 3.
MaxPerDay int
// Today is marked; zero uses the system clock.
Today core.Date
Hour12 bool
Disabled bool
Label string
}
CalendarMonthViewOptions configure a CalendarMonthView.
type CalendarOptions ¶
type CalendarOptions struct {
// Min and Max bound choosable days; zero is open.
Min, Max core.Date
// DisableDate marks single days that cannot be chosen.
DisableDate func(core.Date) bool
WeekStart WeekStart
// Today is marked; zero uses the system clock.
Today core.Date
Disabled bool
// Label names the calendar for assistive technology.
Label string
}
CalendarOptions configure a Calendar.
type CalendarViewResult ¶
CalendarViewResult is a view and what the user asked.
func AgendaView ¶
func AgendaView(c *ui.Context, events []CalendarEvent, opts AgendaViewOptions) CalendarViewResult
AgendaView lists events by day, building only visible rows.
Example ¶
loc := time.Local
events := exampleEvents(loc)
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
opts := datetime.AgendaViewOptions{Location: loc, From: core.Date{Year: 2026, Month: time.October, Day: 12}, Days: 14}
if id, ok := datetime.AgendaView(c, events, opts).Opened(); ok {
fmt.Println("open", id)
}
}
ui.Render(view, 400, 300, 1)
func CalendarDayView ¶
func CalendarDayView(c *ui.Context, day *core.Date, events []CalendarEvent, opts CalendarDayViewOptions) CalendarViewResult
CalendarDayView shows one day's time grid.
Example ¶
loc := time.Local
events := exampleEvents(loc)
day := core.Date{Year: 2026, Month: time.October, Day: 14}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if id, ok := datetime.CalendarDayView(c, &day, events, datetime.CalendarDayViewOptions{Location: loc}).Opened(); ok {
fmt.Println("open", id)
}
}
ui.Render(view, 400, 300, 1)
func CalendarMonthView ¶
func CalendarMonthView(c *ui.Context, month *YearMonth, events []CalendarEvent, opts CalendarMonthViewOptions) CalendarViewResult
CalendarMonthView shows a month of events; drags reschedule them.
Example ¶
loc := time.Local
events := exampleEvents(loc)
month := datetime.YearMonth{Year: 2026, Month: time.October}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
r := datetime.CalendarMonthView(c, &month, events, datetime.CalendarMonthViewOptions{Location: loc})
if ch, ok := r.Changed(); ok {
fmt.Println("move", ch.ID, "to", ch.Start)
}
}
ui.Render(view, 400, 300, 1)
func CalendarWeekView ¶
func CalendarWeekView(c *ui.Context, week *core.Date, events []CalendarEvent, opts CalendarWeekViewOptions) CalendarViewResult
CalendarWeekView shows *week as a time grid; drags edit events.
Example ¶
loc := time.Local
events := exampleEvents(loc)
week := core.Date{Year: 2026, Month: time.October, Day: 14}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
r := datetime.CalendarWeekView(c, &week, events, datetime.CalendarWeekViewOptions{Location: loc, SlotMinutes: 15})
if ch, ok := r.Changed(); ok && ch.Kind == datetime.CalendarCreate {
fmt.Println("new event", ch.Start, ch.End)
}
}
ui.Render(view, 400, 300, 1)
func YearView ¶
func YearView(c *ui.Context, year *int, events []CalendarEvent, opts YearViewOptions) CalendarViewResult
YearView shows twelve months with busy-day dots.
Example ¶
loc := time.Local
events := exampleEvents(loc)
year := 2026
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if day, ok := datetime.YearView(c, &year, events, datetime.YearViewOptions{Location: loc}).DayChosen(); ok {
fmt.Println("go to", day)
}
}
ui.Render(view, 400, 300, 1)
func (CalendarViewResult) Changed ¶
func (r CalendarViewResult) Changed() (CalendarChange, bool)
Changed returns the move, resize or creation the user made.
func (CalendarViewResult) DayChosen ¶
func (r CalendarViewResult) DayChosen() (core.Date, bool)
DayChosen returns the day the user activated.
func (CalendarViewResult) Opened ¶
func (r CalendarViewResult) Opened() (string, bool)
Opened returns the event the user activated.
type CalendarWeekViewOptions ¶
type CalendarWeekViewOptions struct {
// Location is the zone days are cut in; required.
Location *time.Location
// Version must change when events change in place.
Version int
WeekStart WeekStart
// SlotMinutes is the grid step; zero means 30.
SlotMinutes int
// Today is marked; zero uses the system clock.
Today core.Date
// Now places the current-time line; zero uses the system clock.
Now time.Time
Hour12 bool
Disabled bool
Label string
}
CalendarWeekViewOptions configure a CalendarWeekView.
type CountdownFormat ¶
type CountdownFormat int
CountdownFormat chooses how the time left reads.
const ( // CountdownClock reads 01:02:03, with days as "2d" first. CountdownClock CountdownFormat = iota // CountdownWords reads "1 h 2 min 3 s". CountdownWords )
type CountdownOptions ¶
type CountdownOptions struct {
Format CountdownFormat
// Now fixes the clock and stops updates.
Now time.Time
Label string
}
CountdownOptions configure a Countdown.
type CountdownResult ¶
CountdownResult is the countdown and its finish.
func Countdown ¶
func Countdown(c *ui.Context, deadline time.Time, opts CountdownOptions) CountdownResult
Countdown shows the time left, ticking each second while shown.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
deadline := time.Date(2026, time.December, 31, 23, 59, 59, 0, time.Local)
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.Countdown(c, deadline, datetime.CountdownOptions{}).Finished() {
fmt.Println("happy new year")
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func (CountdownResult) Finished ¶
func (r CountdownResult) Finished() bool
Finished reports reaching zero, once per deadline.
type CronEditorOptions ¶
type CronEditorOptions struct {
// Location is the zone runs are computed in; required.
Location *time.Location
// Now starts the preview; zero uses the system clock.
Now time.Time
// Runs is how many next runs show; zero means 5.
Runs int
Hour12 bool
Disabled bool
Label string
}
CronEditorOptions configure a CronEditor.
type CronError ¶
type CronError struct {
// Field is 0 to 4, or -1 for the count.
Field int
Problem CronProblem
// Text is the offending part.
Text string
}
CronError locates a problem in a cron expression.
type CronProblem ¶
type CronProblem int
CronProblem is what is wrong with a cron field.
const ( CronFieldCount CronProblem = iota CronEmptyItem CronBadStep CronNotNumber CronOutOfRange CronBackwards )
type CronSchedule ¶
type CronSchedule struct {
// contains filtered or unexported fields
}
CronSchedule is a parsed five-field cron expression.
func ParseCron ¶
func ParseCron(expr string) (CronSchedule, error)
ParseCron parses standard five-field cron with names.
type CurrentTimeIndicatorOptions ¶
type CurrentTimeIndicatorOptions struct {
// Location is the zone of the day shown; required.
Location *time.Location
// Day is the day the parent spans; zero means today.
Day core.Date
// Now overrides the clock; zero uses the system clock.
Now time.Time
Hour12 bool
}
CurrentTimeIndicatorOptions configure a CurrentTimeIndicator.
type DatePickerOptions ¶
type DatePickerOptions struct {
// Layout is the Go time layout typed and shown; empty uses 2006-01-02.
Layout string
// Min and Max bound the dates accepted; zero leaves a side open.
Min, Max core.Date
DisableDate func(core.Date) bool
WeekStart WeekStart
// Today is marked in the calendar; zero uses the system clock.
Today core.Date
// Clearable shows a clear button and accepts empty text as no date.
Clearable bool
// Placeholder shows in the empty field; empty uses the built-in copy.
Placeholder string
Disabled bool
// ReadOnly keeps the text focusable and copyable but blocks edits and the popup.
ReadOnly bool
// Label names the field for assistive technology.
Label string
}
DatePickerOptions configure a DatePicker.
type DateRange ¶
DateRange is an inclusive span of days. The zero value means no range.
type DateRangePickerOptions ¶
type DateRangePickerOptions struct {
// Layout is the Go time layout shown; empty uses 2006-01-02.
Layout string
// Min and Max bound both ends; zero leaves a side open.
Min, Max core.Date
// DisableDate marks days that neither end nor the span may include.
DisableDate func(core.Date) bool
WeekStart WeekStart
// Today is marked in the calendar; zero uses the system clock.
Today core.Date
Disabled bool
// ReadOnly keeps the field focusable and copyable but blocks the popup.
ReadOnly bool
// Label names the field for assistive technology.
Label string
}
DateRangePickerOptions configure a DateRangePicker.
type DateTimePickerOptions ¶
type DateTimePickerOptions struct {
// Location is the time zone the user edits in; required.
Location *time.Location
// Layout is the Go layout of the date part; empty uses 2006-01-02.
Layout string
// Min and Max bound the instant; zero leaves a side open.
Min, Max time.Time
Seconds bool
Hour12 bool
MinuteStep int
WeekStart WeekStart
// Today is marked in the calendar; zero uses the system clock.
Today core.Date
Disabled bool
// ReadOnly keeps the field focusable and copyable but blocks the popup.
ReadOnly bool
// Label names the field for assistive technology.
Label string
}
DateTimePickerOptions configure a DateTimePicker.
type DateTimeResult ¶
type DateTimeResult struct {
Element ui.Element
// Input is the text field inside, for labels and focus; nil without one.
Input ui.Element
// contains filtered or unexported fields
}
DateTimeResult is a date or time component and what happened to it this frame.
func Calendar ¶
func Calendar(c *ui.Context, value *core.Date, opts CalendarOptions) DateTimeResult
Calendar shows one month and chooses a day into *value.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
day := core.Date{Year: 2026, Month: time.October, Day: 5}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
if datetime.Calendar(c, &day, datetime.CalendarOptions{WeekStart: datetime.WeekStartMonday}).Changed() {
fmt.Println("chosen", day)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func DatePicker ¶
func DatePicker(c *ui.Context, value *core.Date, opts DatePickerOptions) DateTimeResult
DatePicker types or picks *value; invalid text is kept and reported.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
due := core.Date{Year: 2026, Month: time.October, Day: 5}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
opts := datetime.DatePickerOptions{Label: "Due date", Clearable: true,
Min: core.Date{Year: 2026, Month: time.January, Day: 1}}
if datetime.DatePicker(c, &due, opts).Changed() {
fmt.Println("due", due)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func DateRangePicker ¶
func DateRangePicker(c *ui.Context, value *DateRange, opts DateRangePickerOptions) DateTimeResult
DateRangePicker picks start and end; Confirm writes *value.
Example ¶
package main
import (
"fmt"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
var stay datetime.DateRange
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
r := datetime.DateRangePicker(c, &stay, datetime.DateRangePickerOptions{Label: "Stay"})
if r.Changed() {
fmt.Println("stay", stay.Start, stay.End, stay.Days())
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func DateTimePicker ¶
func DateTimePicker(c *ui.Context, value *time.Time, opts DateTimePickerOptions) DateTimeResult
DateTimePicker edits *value as wall time in opts.Location.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
tokyo, err := time.LoadLocation("Asia/Tokyo")
if err != nil {
panic(err)
}
var meeting time.Time
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
opts := datetime.DateTimePickerOptions{Label: "Meeting", Location: tokyo, MinuteStep: 15}
if datetime.DateTimePicker(c, &meeting, opts).Changed() {
fmt.Println("meeting", meeting)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func MonthPicker ¶
func MonthPicker(c *ui.Context, value *YearMonth, opts MonthPickerOptions) DateTimeResult
MonthPicker chooses a month into *value from a year page.
Example ¶
package main
import (
"fmt"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
var month datetime.YearMonth
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
opts := datetime.MonthPickerOptions{Label: "Billing month", Clearable: true}
if datetime.MonthPicker(c, &month, opts).Changed() {
fmt.Println("month", month)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func NewDateTimeResult ¶
func NewDateTimeResult(e, input ui.Element, changed, canceled bool) DateTimeResult
NewDateTimeResult reports a date or time control built from parts in another component.
func TimePicker ¶
func TimePicker(c *ui.Context, value *TimeOfDay, opts TimePickerOptions) DateTimeResult
TimePicker edits *value in segments or a popup.
Example ¶
package main
import (
"fmt"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
alarm := datetime.TimeOfDay{Hour: 7, Minute: 30}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
opts := datetime.TimePickerOptions{Label: "Alarm", Hour12: true, MinuteStep: 5}
if datetime.TimePicker(c, &alarm, opts).Changed() {
fmt.Println("alarm", alarm)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func TimeRangePicker ¶
func TimeRangePicker(c *ui.Context, value *TimeRange, opts TimeRangePickerOptions) DateTimeResult
TimeRangePicker writes *value only when the range is valid.
Example ¶
package main
import (
"fmt"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
shift := datetime.TimeRange{Start: datetime.TimeOfDay{Hour: 22}, End: datetime.TimeOfDay{Hour: 6}}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
opts := datetime.TimeRangePickerOptions{Label: "Night shift", AllowOvernight: true}
if datetime.TimeRangePicker(c, &shift, opts).Changed() {
fmt.Println("shift", shift.Start, shift.End, shift.Overnight())
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func YearPicker ¶
func YearPicker(c *ui.Context, value *int, opts YearPickerOptions) DateTimeResult
YearPicker chooses a year into *value from a decade page; zero is none.
Example ¶
package main
import (
"fmt"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
year := 2026
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
opts := datetime.YearPickerOptions{Label: "Vintage", Min: 1990, Max: 2030}
if datetime.YearPicker(c, &year, opts).Changed() {
fmt.Println("year", year)
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func (DateTimeResult) Canceled ¶
func (r DateTimeResult) Canceled() bool
Canceled reports whether the user discarded a pending edit this frame.
func (DateTimeResult) Changed ¶
func (r DateTimeResult) Changed() bool
Changed reports whether the component wrote a new value this frame.
type DurationPickerOptions ¶
type DurationPickerOptions struct {
// Seconds adds a seconds field.
Seconds bool
// Min and Max bound the duration; zero Max means 99:59:59.
Min, Max time.Duration
Disabled bool
Label string
}
DurationPickerOptions configure a DurationPicker.
type EventChipOptions ¶
type EventChipOptions struct {
// Location is the zone the time shows in; required.
Location *time.Location
Hour12 bool
// Inline puts the start time and title on one line.
Inline bool
Selected bool
Disabled bool
}
EventChipOptions configure an EventChip.
type EventColor ¶
type EventColor int
EventColor picks an event's color from the theme's event palette.
const ( EventAccent EventColor = iota EventInfo EventSuccess EventWarning EventDanger EventNeutral )
type EventEditorOptions ¶
type EventEditorOptions struct {
// Location is the zone times are edited in; required.
Location *time.Location
Hour12 bool
WeekStart WeekStart
Disabled bool
Label string
}
EventEditorOptions configure an EventEditor.
type EventEditorResult ¶
EventEditorResult is the editor and its save or cancel.
func EventEditor ¶
func EventEditor(c *ui.Context, ev *CalendarEvent, opts EventEditorOptions) EventEditorResult
EventEditor edits a copy of *ev; Save checks and writes.
Example ¶
loc := time.Local
ev := exampleEvents(loc)[0]
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
r := datetime.EventEditor(c, &ev, datetime.EventEditorOptions{Location: loc})
if r.Saved() {
fmt.Println("saved", ev.Title, ev.Start)
}
}
ui.Render(view, 400, 300, 1)
func (EventEditorResult) Canceled ¶
func (r EventEditorResult) Canceled() bool
Canceled reports that the user discarded the draft.
func (EventEditorResult) Saved ¶
func (r EventEditorResult) Saved() bool
Saved reports a valid draft written to the event.
type EventPopoverOptions ¶
type EventPopoverOptions struct {
// Location is the zone times show in; required.
Location *time.Location
Hour12 bool
// ReadOnly hides the edit and delete actions.
ReadOnly bool
Disabled bool
}
EventPopoverOptions configure an EventPopover.
type EventPopoverResult ¶
EventPopoverResult is the popover and the action the user chose.
func EventPopover ¶
func EventPopover(c *ui.Context, anchor ui.Element, open *bool, ev CalendarEvent, opts EventPopoverOptions) EventPopoverResult
EventPopover summarizes an event beside anchor while *open.
Example ¶
loc := time.Local
ev := exampleEvents(loc)[0]
open := false
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
chip := datetime.EventChip(c, ev, datetime.EventChipOptions{Location: loc})
if chip.Clicked() {
open = true
}
r := datetime.EventPopover(c, chip, &open, ev, datetime.EventPopoverOptions{Location: loc})
if r.Delete() {
fmt.Println("delete", ev.ID)
}
}
ui.Render(view, 400, 300, 1)
func (EventPopoverResult) Delete ¶
func (r EventPopoverResult) Delete() bool
Delete reports a click on Delete.
func (EventPopoverResult) Edit ¶
func (r EventPopoverResult) Edit() bool
Edit reports a click on Edit.
type MonthPickerOptions ¶
type MonthPickerOptions struct {
// Min and Max bound the months chosen; zero leaves a side open.
Min, Max YearMonth
DisableMonth func(YearMonth) bool
Clearable bool
// Today marks the current month; zero uses the system clock.
Today core.Date
Disabled bool
// ReadOnly keeps the field focusable and copyable but blocks the popup and clearing.
ReadOnly bool
// Label names the field for assistive technology.
Label string
}
MonthPickerOptions configure a MonthPicker.
type Recurrence ¶
type Recurrence struct {
Unit RepeatUnit
Interval int
Weekdays []time.Weekday
End RepeatEnd
Count int
Until core.Date
}
Recurrence repeats every Interval units, on Weekdays when weekly.
type RecurrenceEditorOptions ¶
type RecurrenceEditorOptions struct {
// Start is the first occurrence; Until must not precede it.
Start core.Date
WeekStart WeekStart
Disabled bool
Label string
}
RecurrenceEditorOptions configure a RecurrenceEditor.
type RecurrenceResult ¶
RecurrenceResult is the editor, its change and its problem.
func RecurrenceEditor ¶
func RecurrenceEditor(c *ui.Context, rule *Recurrence, opts RecurrenceEditorOptions) RecurrenceResult
RecurrenceEditor edits a repeat rule and when it ends.
Example ¶
package main
import (
"fmt"
"time"
"github.com/egoist/mygo/ui"
"github.com/ELY-Open-Source/MujicaUI/core"
"github.com/ELY-Open-Source/MujicaUI/datetime"
)
func main() {
rule := datetime.Recurrence{Unit: datetime.RepeatWeekly, Interval: 1, Weekdays: []time.Weekday{time.Monday}}
view := func(c *ui.Context) {
core.Use(c, core.Settings{})
r := datetime.RecurrenceEditor(c, &rule, datetime.RecurrenceEditorOptions{Start: core.Date{Year: 2026, Month: time.October, Day: 5}})
if r.Changed() && r.Problem() == "" {
fmt.Println(datetime.RecurrenceSummary(c, rule))
}
}
ui.Render(view, 400, 300, 1)
}
Output:
func (RecurrenceResult) Changed ¶
func (r RecurrenceResult) Changed() bool
Changed reports whether the user changed the rule this frame.
func (RecurrenceResult) Problem ¶
func (r RecurrenceResult) Problem() string
Problem explains why the rule cannot be saved.
type RelativeTimeOptions ¶
type RelativeTimeOptions struct {
// Location is the tooltip's zone; required.
Location *time.Location
// Now fixes the clock and stops updates.
Now time.Time
Hour12 bool
}
RelativeTimeOptions configure a RelativeTime.
type ReminderPickerOptions ¶
type ReminderPickerOptions struct {
// Choices are the lead times offered; empty uses defaults.
Choices []time.Duration
// Max limits how many are set; zero means any.
Max int
Disabled bool
Label string
}
ReminderPickerOptions configure a ReminderPicker.
type RepeatUnit ¶
type RepeatUnit int
RepeatUnit is how often a rule repeats; zero never does.
const ( RepeatNone RepeatUnit = iota RepeatDaily RepeatWeekly RepeatMonthly RepeatYearly )
type StopwatchOptions ¶
type StopwatchOptions struct {
// Now fixes the clock and stops ticking.
Now time.Time
Disabled bool
Label string
}
StopwatchOptions configure a Stopwatch.
type StopwatchState ¶
type StopwatchState struct {
// Laps are the elapsed times at each lap, oldest first.
Laps []time.Duration
// contains filtered or unexported fields
}
StopwatchState is the caller's run and laps.
func (*StopwatchState) Elapsed ¶
func (s *StopwatchState) Elapsed(now time.Time) time.Duration
Elapsed returns the time measured at now.
func (*StopwatchState) Running ¶
func (s *StopwatchState) Running() bool
Running reports whether the stopwatch is counting.
type TimeOfDay ¶
type TimeOfDay struct {
Hour, Minute, Second int
}
TimeOfDay is a wall-clock time with no date and no location.
type TimePickerOptions ¶
type TimePickerOptions struct {
// Seconds shows and edits the seconds.
Seconds bool
// Hour12 shows a 12-hour clock with AM and PM.
Hour12 bool
// MinuteStep and SecondStep must divide 60; zero means 1.
MinuteStep, SecondStep int
// Min and Max bound the time; a zero Max means 23:59:59.
Min, Max TimeOfDay
Disabled bool
// ReadOnly keeps the segments focusable and copyable but blocks edits and the popup.
ReadOnly bool
// Label names the field for assistive technology.
Label string
}
TimePickerOptions configure a TimePicker.
type TimeRange ¶
type TimeRange struct {
Start, End TimeOfDay
}
TimeRange is a span of day; End before Start means next day.
type TimeRangePickerOptions ¶
type TimeRangePickerOptions struct {
Seconds bool
Hour12 bool
// MinuteStep and SecondStep must divide 60; zero means 1.
MinuteStep, SecondStep int
// Min and Max bound both ends; a zero Max means 23:59:59.
Min, Max TimeOfDay
// AllowOvernight accepts an end before the start, meaning the next day.
AllowOvernight bool
Disabled bool
// ReadOnly keeps both ends focusable and copyable but blocks edits.
ReadOnly bool
// Label names the pair for assistive technology.
Label string
}
TimeRangePickerOptions configure a TimeRangePicker.
type TimezoneSelectOptions ¶
type TimezoneSelectOptions struct {
// Zones are the IANA names offered; empty uses built-ins.
Zones []string
// Common are pinned first; empty uses a built-in short list.
Common []string
// Now dates the offsets; zero uses the system clock.
Now time.Time
Disabled bool
Label string
}
TimezoneSelectOptions configure a TimezoneSelect.
type WeekPickerOptions ¶
type WeekPickerOptions struct {
WeekStart WeekStart
// Min and Max bound the chosen week's days.
Min, Max core.Date
// Today is marked; zero uses the system clock.
Today core.Date
Clearable bool
Disabled bool
Label string
}
WeekPickerOptions configure a WeekPicker.
type YearMonth ¶
YearMonth is a month of a year. The zero value means no month.
type YearPickerOptions ¶
type YearPickerOptions struct {
// Min and Max bound the years chosen; zero leaves a side open.
Min, Max int
DisableYear func(int) bool
Clearable bool
// Today marks the current year; zero uses the system clock.
Today core.Date
Disabled bool
// ReadOnly keeps the field focusable and copyable but blocks the popup and clearing.
ReadOnly bool
// Label names the field for assistive technology.
Label string
}
YearPickerOptions configure a YearPicker.
type YearViewOptions ¶
type YearViewOptions struct {
// Location is the zone days are cut in; required.
Location *time.Location
// Version must change when events change in place.
Version int
WeekStart WeekStart
// Today is marked; zero uses the system clock.
Today core.Date
Disabled bool
Label string
}
YearViewOptions configure a YearView.
Source Files
¶
- agenda_view.go
- attendee_list.go
- availability_picker.go
- calendar.go
- calendar_day_view.go
- calendar_events.go
- calendar_month_view.go
- calendar_time_grid.go
- calendar_week_view.go
- countdown.go
- cron_editor.go
- current_time_indicator.go
- date_picker.go
- date_range_picker.go
- date_time_picker.go
- datetime_grid.go
- datetime_result.go
- doc.go
- duration_picker.go
- event_chip.go
- event_editor.go
- event_popover.go
- month_picker.go
- recurrence_editor.go
- relative_time.go
- reminder_picker.go
- stopwatch.go
- time_picker.go
- time_picker_popup.go
- time_range_picker.go
- timezone_select.go
- week_picker.go
- year_picker.go
- year_view.go