zenity/date_darwin.go

36 lines
628 B
Go
Raw Permalink Normal View History

2022-03-24 12:15:11 -04:00
package zenity
import (
"time"
"github.com/ncruces/zenity/internal/zenutil"
)
2022-03-30 10:36:50 -04:00
func calendar(text string, opts options) (t time.Time, err error) {
2022-03-24 12:15:11 -04:00
var date zenutil.Date
2022-03-28 15:22:39 -04:00
date.OK, date.Cancel, date.Extra = getAlertButtons(opts)
2022-05-02 10:03:48 -04:00
date.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-03-30 10:36:50 -04:00
unix := opts.time.Unix()
date.Date = &unix
2022-03-28 22:05:46 -04:00
}
2022-03-24 12:15:11 -04:00
if opts.title != nil {
date.Text = *opts.title
date.Info = text
} else {
date.Text = text
}
out, err := zenutil.Run(opts.ctx, "date", date)
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
}