zenity/date_darwin.go

38 lines
686 B
Go
Raw Normal View History

2022-03-24 12:15:11 -04:00
package zenity
import (
"time"
2024-07-10 00:06:01 -04:00
"git.bigun.dev/evan/zenity/internal/zenutil"
2022-03-24 12:15:11 -04:00
)
2022-03-30 10:36:50 -04:00
func calendar(text string, opts options) (t time.Time, err error) {
2022-06-01 19:00:08 -04:00
var data zenutil.Date
2022-03-24 12:15:11 -04:00
2022-06-01 19:00:08 -04:00
data.OK, data.Cancel, data.Extra = getAlertButtons(opts)
data.Format, err = zenutil.DateUTS35()
2022-03-30 10:36:50 -04:00
if err != nil {
return
}
2022-03-28 22:05:46 -04:00
if opts.time != nil {
2022-12-14 19:26:34 -05:00
data.Date = ptr(opts.time.Unix())
2022-03-28 22:05:46 -04:00
}
2022-03-24 12:15:11 -04:00
if opts.title != nil {
2022-06-01 19:00:08 -04:00
data.Text = *opts.title
data.Info = text
2022-03-24 12:15:11 -04:00
} else {
2022-06-01 19:00:08 -04:00
data.Text = text
}
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i
2022-03-24 12:15:11 -04:00
}
2022-06-01 19:00:08 -04:00
out, err := zenutil.Run(opts.ctx, "date", data)
2022-03-24 12:15:11 -04:00
str, err := strResult(opts, out, err)
if err != nil {
2022-03-30 10:36:50 -04:00
return
2022-03-24 12:15:11 -04:00
}
2022-05-02 10:03:48 -04:00
return zenutil.DateParse(str)
2022-03-24 12:15:11 -04:00
}