diff --git a/when.go b/when.go index ba537b4..f7cdd3d 100644 --- a/when.go +++ b/when.go @@ -31,6 +31,8 @@ type Result struct { Source string // Time is an output time Time time.Time + // Duration is an output relative duration + Duration time.Duration } // Parse returns Result and error if any. If have not matches it returns nil, nil. @@ -113,6 +115,8 @@ func (p *Parser) Parse(text string, base time.Time) (*Result, error) { return nil, errors.Wrap(err, "bind context") } + res.Duration = ctx.Duration + return &res, nil }