-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
date_unix.go
31 lines (26 loc) · 815 Bytes
/
date_unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//go:build !windows && !darwin
package zenity
import (
"strconv"
"time"
"github.com/ncruces/zenity/internal/zenutil"
)
func calendar(text string, opts options) (time.Time, error) {
args := []string{"--calendar", "--text", quoteMarkup(text), "--date-format", zenutil.DateFormat}
args = appendGeneral(args, opts)
args = appendButtons(args, opts)
args = appendWidthHeight(args, opts)
args = appendWindowIcon(args, opts)
if opts.time != nil {
year, month, day := opts.time.Date()
args = append(args, "--month", strconv.Itoa(int(month)))
args = append(args, "--day", strconv.Itoa(day))
args = append(args, "--year", strconv.Itoa(year))
}
out, err := zenutil.Run(opts.ctx, args)
str, err := strResult(opts, out, err)
if err != nil {
return time.Time{}, err
}
return zenutil.DateParse(str)
}