Truncate a timestamp to the nearest minute

Hi,

I would like to create an instance of std::time::Instant representing the top of the next minute. In other languages or libraries, it would be a simple matter to create a timestamp object of now, add 1 minute, then truncate the result to set the seconds field to zero, but I can't find a way to do that in rust.

Are there methods or tricks that I am missing, perhaps via the unix epoch?

Is there another data structure representing a date & time that could be manipulated in that way, and then used to construct an Instant?

Thanks.

std::time::SystemTime is a better choice for such things.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.