From 7cc25e3bdd8c540b243f70c366ba1f1856fcd9e9 Mon Sep 17 00:00:00 2001 From: Tomas Aschan <1550920+tomasaschan@users.noreply.github.com> Date: Wed, 16 Jul 2025 23:37:38 +0200 Subject: Don't export `TimeValue` (yet) --- time.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/time.go b/time.go index 7964346..dbaeeab 100644 --- a/time.go +++ b/time.go @@ -7,21 +7,21 @@ import ( ) // TimeValue adapts time.Time for use as a flag. -type TimeValue struct { +type timeValue struct { *time.Time formats []string } -func newTimeValue(val time.Time, p *time.Time, formats []string) *TimeValue { +func newTimeValue(val time.Time, p *time.Time, formats []string) *timeValue { *p = val - return &TimeValue{ + return &timeValue{ Time: p, formats: formats, } } // Set time.Time value from string based on accepted formats. -func (d *TimeValue) Set(s string) error { +func (d *timeValue) Set(s string) error { s = strings.TrimSpace(s) for _, f := range d.formats { v, err := time.Parse(f, s) @@ -44,11 +44,11 @@ func (d *TimeValue) Set(s string) error { } // Type name for time.Time flags. -func (d *TimeValue) Type() string { +func (d *timeValue) Type() string { return "time" } -func (d *TimeValue) String() string { return d.Time.Format(time.RFC3339Nano) } +func (d *timeValue) String() string { 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) { @@ -63,7 +63,7 @@ func (f *FlagSet) GetTime(name string) (time.Time, error) { return time.Time{}, err } - val, ok := flag.Value.(*TimeValue) + val, ok := flag.Value.(*timeValue) if !ok { return time.Time{}, fmt.Errorf("value %s is not a time", flag.Value) } -- cgit v1.2.3