zenity/date_darwin.go

37 lines
694 B
Go
Raw Permalink Normal View History

2022-03-24 12:15:11 -04:00
package zenity
import (
"time"
2022-04-01 09:00:06 -04:00
"github.com/ncruces/go-strftime"
2022-03-24 12:15:11 -04:00
"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-03-30 10:36:50 -04:00
date.Format, err = strftime.UTS35(zenutil.DateFormat)
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-03-30 10:36:50 -04:00
return strftime.Parse(zenutil.DateFormat, str)
2022-03-24 12:15:11 -04:00
}