aboutsummaryrefslogtreecommitdiff
path: root/time.go
diff options
context:
space:
mode:
authorOliver Kuckertz <[email protected]>2025-07-24 17:52:43 +0200
committerOliver Kuckertz <[email protected]>2025-07-24 17:54:07 +0200
commit1b52f7648f880d6ef6aaa19e45b102edadd6c50a (patch)
tree878a2dedc3c9386172ee78fe799e24b6a22c9166 /time.go
parentc78f730fb023e4012c4097b24408867cd5c5bdde (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.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/time.go b/time.go
index dc02480..3dee424 100644
--- a/time.go
+++ b/time.go
@@ -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) {