You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
578 B

4 years ago
package value
import (
"time"
"gitoa.ru/go-4devs/console/input/value/flag"
4 years ago
)
type Time struct {
empty
4 years ago
Val []time.Time
4 years ago
Flag flag.Flag
4 years ago
}
func (t *Time) Append(in string) error {
v, err := time.Parse(time.RFC3339, in)
if err != nil {
return err
}
t.Val = append(t.Val, v)
return nil
}
func (t *Time) Time() time.Time {
if !t.Flag.IsArray() && len(t.Val) == 1 {
return t.Val[0]
}
return time.Time{}
}
func (t *Time) Times() []time.Time {
return t.Val
}
func (t *Time) Amy() interface{} {
4 years ago
if t.Flag.IsArray() {
4 years ago
return t.Times()
}
return t.Time()
}