diff options
| author | Oliver Kuckertz <[email protected]> | 2025-07-24 17:52:43 +0200 |
|---|---|---|
| committer | Oliver Kuckertz <[email protected]> | 2025-07-24 17:54:07 +0200 |
| commit | 1b52f7648f880d6ef6aaa19e45b102edadd6c50a (patch) | |
| tree | 878a2dedc3c9386172ee78fe799e24b6a22c9166 /time.go | |
| parent | c78f730fb023e4012c4097b24408867cd5c5bdde (diff) | |
Omit zero time.Time default from usage line
This was missed in #348, there previously was no way to omit the
default value. Treating zero timestamp values as canary for absence
of a default is in line with other flag types, e.g. zero ints.
Diffstat (limited to 'time.go')
| -rw-r--r-- | time.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -48,7 +48,13 @@ func (d *timeValue) Type() string { return "time" } -func (d *timeValue) String() string { return d.Time.Format(time.RFC3339Nano) } +func (d *timeValue) String() string { + if d.Time.IsZero() { + return "" + } else { + return d.Time.Format(time.RFC3339Nano) + } +} // GetTime return the time value of a flag with the given name func (f *FlagSet) GetTime(name string) (time.Time, error) { |
