Skip to content

Commit e3be2eb

Browse files
committed
Reduce duplication by forwarding to sibling functions
1 parent 7cc25e3 commit e3be2eb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

‎time.go‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (f *FlagSet) GetTime(name string) (time.Time, error) {
7474
// TimeVar defines a time.Time flag with specified name, default value, and usage string.
7575
// The argument p points to a time.Time variable in which to store the value of the flag.
7676
func (f *FlagSet) TimeVar(p *time.Time, name string, value time.Time, formats []string, usage string) {
77-
f.VarP(newTimeValue(value, p, formats), name, "", usage)
77+
f.TimeVarP(p, name, "", value, formats, usage)
7878
}
7979

8080
// TimeVarP is like TimeVar, but accepts a shorthand letter that can be used after a single dash.
@@ -85,7 +85,7 @@ func (f *FlagSet) TimeVarP(p *time.Time, name, shorthand string, value time.Time
8585
// TimeVar defines a time.Time flag with specified name, default value, and usage string.
8686
// The argument p points to a time.Time variable in which to store the value of the flag.
8787
func TimeVar(p *time.Time, name string, value time.Time, formats []string, usage string) {
88-
CommandLine.VarP(newTimeValue(value, p, formats), name, "", usage)
88+
CommandLine.TimeVarP(p, name, "", value, formats, usage)
8989
}
9090

9191
// TimeVarP is like TimeVar, but accepts a shorthand letter that can be used after a single dash.
@@ -96,9 +96,7 @@ func TimeVarP(p *time.Time, name, shorthand string, value time.Time, formats []s
9696
// Time defines a time.Time flag with specified name, default value, and usage string.
9797
// The return value is the address of a time.Time variable that stores the value of the flag.
9898
func (f *FlagSet) Time(name string, value time.Time, formats []string, usage string) *time.Time {
99-
p := new(time.Time)
100-
f.TimeVarP(p, name, "", value, formats, usage)
101-
return p
99+
return f.TimeP(name, "", value, formats, usage)
102100
}
103101

104102
// TimeP is like Time, but accepts a shorthand letter that can be used after a single dash.

0 commit comments

Comments
 (0)