Skip to content

Proposal: Add time.Until() to the time package #14595

Closed
@SamWhited

Description

@SamWhited

I'd like to propose that a time.Until(t time.Time) time.Duration function be added to the time package to compliment the existing Since() shortcut. This would make writing expressions with an expiration time a bit more readable:

<-After(time.Until(expirationTime))

vs.

<-After(expirationTime.Sub(time.Now()))

While it's still fairly obvious what the second one does, it takes a little longer to recognize "sub" as subtraction than just seeing the symbol. Also keeping time expressions more or less readable as english is a nice benefit of having the until shortcut (as you can do with the existing since function).

If this accepted, I've got a CL here for review.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions