mirror of
https://github.com/datarhei/core.git
synced 2025-09-27 04:16:25 +08:00

If the config on the disk doesn't have all fields, then the missing fields are now populated with their defaults.
37 lines
494 B
Go
37 lines
494 B
Go
package value
|
|
|
|
import "time"
|
|
|
|
// time
|
|
|
|
type Time time.Time
|
|
|
|
func NewTime(p *time.Time, val time.Time) *Time {
|
|
*p = val
|
|
|
|
return (*Time)(p)
|
|
}
|
|
|
|
func (u *Time) Set(val string) error {
|
|
v, err := time.Parse(time.RFC3339, val)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*u = Time(v)
|
|
return nil
|
|
}
|
|
|
|
func (u *Time) String() string {
|
|
v := time.Time(*u)
|
|
return v.Format(time.RFC3339)
|
|
}
|
|
|
|
func (u *Time) Validate() error {
|
|
return nil
|
|
}
|
|
|
|
func (u *Time) IsEmpty() bool {
|
|
v := time.Time(*u)
|
|
return v.IsZero()
|
|
}
|