zenity/date_darwin.go

33 lines
666 B
Go
Raw Normal View History

2022-03-24 12:15:11 -04:00
package zenity
import (
"time"
"github.com/ncruces/zenity/internal/zenutil"
)
func calendar(text string, opts options) (time.Time, error) {
var date zenutil.Date
2022-03-28 15:22:39 -04:00
date.OK, date.Cancel, date.Extra = getAlertButtons(opts)
2022-03-29 07:53:20 -04:00
date.Format = zenutil.StrftimeUTS35(zenutil.DateFormat)
2022-03-28 22:05:46 -04:00
if opts.time != nil {
date.Date = opts.time.Unix()
}
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 {
return time.Time{}, err
}
2022-03-29 20:28:19 -04:00
layout := zenutil.StrftimeLayout(zenutil.DateFormat)
return time.Parse(layout, str)
2022-03-24 12:15:11 -04:00
}