diff --git a/cmd/zenity/main.go b/cmd/zenity/main.go index 4bca1f6..fe43981 100644 --- a/cmd/zenity/main.go +++ b/cmd/zenity/main.go @@ -116,6 +116,8 @@ func main() { validateFlags() opts := loadFlags() zenutil.Command = true + zenutil.DateUTS35 = func() (string, error) { return strftime.UTS35(zenutil.DateFormat) } + zenutil.DateParse = func(s string) (time.Time, error) { return strftime.Parse(zenutil.DateFormat, s) } if unixeol { zenutil.LineBreak = "\n" } diff --git a/date_darwin.go b/date_darwin.go index 7bb8b7f..a97f11e 100644 --- a/date_darwin.go +++ b/date_darwin.go @@ -3,7 +3,6 @@ package zenity import ( "time" - "github.com/ncruces/go-strftime" "github.com/ncruces/zenity/internal/zenutil" ) @@ -11,7 +10,7 @@ func calendar(text string, opts options) (t time.Time, err error) { var date zenutil.Date date.OK, date.Cancel, date.Extra = getAlertButtons(opts) - date.Format, err = strftime.UTS35(zenutil.DateFormat) + date.Format, err = zenutil.DateUTS35() if err != nil { return } @@ -32,5 +31,5 @@ func calendar(text string, opts options) (t time.Time, err error) { if err != nil { return } - return strftime.Parse(zenutil.DateFormat, str) + return zenutil.DateParse(str) } diff --git a/date_unix.go b/date_unix.go index 90d95de..fc043ef 100644 --- a/date_unix.go +++ b/date_unix.go @@ -6,7 +6,6 @@ import ( "strconv" "time" - "github.com/ncruces/go-strftime" "github.com/ncruces/zenity/internal/zenutil" ) @@ -28,5 +27,5 @@ func calendar(text string, opts options) (time.Time, error) { if err != nil { return time.Time{}, err } - return strftime.Parse(zenutil.DateFormat, str) + return zenutil.DateParse(str) } diff --git a/go.mod b/go.mod index fb75722..6440e03 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 go.uber.org/goleak v1.1.12 // test golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 - golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 + golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba ) require ( diff --git a/go.sum b/go.sum index 64b29ea..9ab6230 100644 --- a/go.sum +++ b/go.sum @@ -42,8 +42,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 h1:Js08h5hqB5xyWR789+QqueR6sDE8mk+YvpETZ+F6X9Y= -golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba h1:AyHWHCBVlIYI5rgEM3o+1PLd0sLPcIAoaUckGQMaWtw= +golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/internal/zenutil/env.go b/internal/zenutil/env.go index 43ff36c..4242b67 100644 --- a/internal/zenutil/env.go +++ b/internal/zenutil/env.go @@ -1,6 +1,8 @@ // Package zenutil is internal. DO NOT USE. package zenutil +import "time" + // These are internal. const ( ErrCanceled = stringErr("dialog canceled") @@ -8,6 +10,16 @@ const ( ErrUnsupported = stringErr("unsupported option") ) +// These are internal. +var ( + Command bool + Timeout int + + DateFormat = "%Y-%m-%d" + DateUTS35 = func() (string, error) { return "yyyy-MM-dd", nil } + DateParse = func(s string) (time.Time, error) { return time.Parse("2006-01-02", s) } +) + type stringErr string func (e stringErr) Error() string { return string(e) } diff --git a/internal/zenutil/env_darwin.go b/internal/zenutil/env_darwin.go index 0b0af9f..39b99f8 100644 --- a/internal/zenutil/env_darwin.go +++ b/internal/zenutil/env_darwin.go @@ -2,9 +2,6 @@ package zenutil // These are internal. var ( - Command bool - Timeout int - Separator = "\x00" - LineBreak = "\n" - DateFormat = "%F" + Separator = "\x00" + LineBreak = "\n" ) diff --git a/internal/zenutil/env_unix.go b/internal/zenutil/env_unix.go index 7c6336f..ad4003b 100644 --- a/internal/zenutil/env_unix.go +++ b/internal/zenutil/env_unix.go @@ -4,9 +4,6 @@ package zenutil // These are internal. var ( - Command bool - Timeout int - Separator = "\x1e" - LineBreak = "\n" - DateFormat = "%F" + Separator = "\x1e" + LineBreak = "\n" ) diff --git a/internal/zenutil/env_windows.go b/internal/zenutil/env_windows.go index 993ea6c..e8e1894 100644 --- a/internal/zenutil/env_windows.go +++ b/internal/zenutil/env_windows.go @@ -2,9 +2,6 @@ package zenutil // These are internal. var ( - Command bool - Timeout int - Separator string - LineBreak = "\r\n" - DateFormat = "%F" + Separator string + LineBreak = "\r\n" )