Function seconds_to_time

Source
pub fn seconds_to_time(seconds: u64) -> (String, String)
Expand description

⚙️ Function: Converts a duration in seconds into a tuple representing minutes and seconds.

This function takes a duration in seconds and converts it into a more human-readable format, returning the number of minutes and the remaining seconds as a tuple of strings. This is useful for displaying game durations or other time intervals in a clear way.

§Parameters:

  • seconds: A u64 value representing the total duration in seconds.

§Returns:

  • (String, String): A tuple where the first value is the number of minutes, and the second value is the number of seconds (formatted as two digits if necessary).

§Example:

This function is useful when converting raw game duration data into a more readable format.

let (minutes, seconds) = seconds_to_time(645);
assert_eq!(minutes, "10");
assert_eq!(seconds, "45");

In this example, 645 seconds are converted to 10 minutes and 45 seconds.

§Notes:

  • The seconds part is always formatted as two digits. For example, if the input is 610 seconds (10 minutes and 10 seconds), the result will be "10", "10".