Skip to content

time: provide Truncate usable for durations > 1 minute #16647

@quentinmit

Description

@quentinmit

The example for time.Time.Truncate suggests truncating by time.Hour, but in fact Truncate does not do what the user probably wants if the timezone is not hour-aligned.

e.g. https://play.golang.org/p/hAfBrYWNeZ

I suggest just removing the time.Hour example, and possibly explicitly suggest that Truncate cannot be used for times >= time.Hour because of timezones.

I doubt we can actually change the implementation of Truncate at this point, so I've marked this a Documentation bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions