From a8406bbc9aa036b215744587967b70510d5d2e04 Mon Sep 17 00:00:00 2001 From: dtookey Date: Sun, 6 Aug 2023 19:25:19 -0400 Subject: [PATCH] HelperFunctions.kt has some documentation --- src/main/kotlin/HelperFunctions.kt | 31 ++++++++---------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/main/kotlin/HelperFunctions.kt b/src/main/kotlin/HelperFunctions.kt index 817edb7..3a83270 100644 --- a/src/main/kotlin/HelperFunctions.kt +++ b/src/main/kotlin/HelperFunctions.kt @@ -13,39 +13,24 @@ object HelperFunctions { 0 } + /** - * Prints a progress report for the current step. + * Prints a progress report to console showing current step, total steps, elapsed time, and estimated remaining time. * - * @param step The current step number. - * @param of The total number of steps. - * @param dur The duration in milliseconds so far. - * - * This method prints a progress report to the console in the format: - * "Step {step} of {of} ({formattedDuration} complete | ~{remainingTime} remaining)" - * - * It calculates the estimated remaining time based on the current duration and - * number of steps completed vs total steps. - * - * The output is printed on the same line to dynamically update the progress. + * @param step The current step number + * @param of The total number of steps + * @param dur The elapsed duration so far in milliseconds */ fun report(step: Int, of: Int, dur: Long) { val remaining = (dur / step) * (of - step) print("\rStep $step of $of (${prettyTimeString(dur)} complete\t|\t~${prettyTimeString(remaining)} remaining) ") } - /** - * Formats the given duration in milliseconds into a human readable time string. + * Converts a duration in milliseconds to a human-readable string. * - * @param durationMillis The duration to format in milliseconds. - * - * @return A formatted time string showing the duration broken down into hours, minutes, and seconds. - * - * This converts the duration into hours, minutes, and seconds based on millis per second, - * minute, and hour constants. It returns a string in the format "XhYmZs" where X, Y, and Z are - * the calculated hours, minutes, and seconds. - * - * If durationMillis is 0, it returns "No time data yet" instead. + * @param durationMillis The duration to convert, in milliseconds + * @return A string representation of the duration, in the format XhYmZs */ fun prettyTimeString(durationMillis: Long): String { if (durationMillis == 0L) {