Files
chain33-dtalk/pkg/time/duration.go
2022-03-17 15:59:24 +08:00

18 lines
335 B
Go

package time
import (
xtime "time"
)
// Duration be used toml unmarshal string time, like 1s, 500ms.
type Duration xtime.Duration
// UnmarshalText unmarshal text to duration.
func (d *Duration) UnmarshalText(text []byte) error {
tmp, err := xtime.ParseDuration(string(text))
if err == nil {
*d = Duration(tmp)
}
return err
}