From 9e7cd3945b8e94121246cd5ebea597ca653d1461 Mon Sep 17 00:00:00 2001 From: AdamMagued Date: Sun, 11 Oct 2026 02:31:18 +0300 Subject: [PATCH] feat: expose Duration in Result --- when.go | 4 ++++ 1 file changed, 4 insertions(+) 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 }