Skip to content

Conversation

@DocMAX
Copy link

@DocMAX DocMAX commented Oct 11, 2025

Add estimated time of arrival (ETA) calculation for device replace operations using progress percentage and elapsed time. The ETA is calculated by determining the total estimated completion time based on current progress ratio and displays the expected completion time in a user-friendly format.

cmds/replace.c Outdated
char string1[80];
char string2[80];
char string3[80];
char eta_str[80];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to replace the immediate number 80 with a macro.

cmds/replace.c Outdated
eta_time = current_time + remaining_time;
struct tm eta_tm_buf;
struct tm *eta_tm = localtime_r(&eta_time, &eta_tm_buf);
strftime(eta_str, sizeof(eta_str), "ETA: %a %b %d %H:%M:%S %Y", eta_tm);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the return value, as it is possible to return 0 when the string buffer is not large enough.

cmds/replace.c Outdated
if (remaining_time > 0 && total_time > elapsed_time) {
eta_time = current_time + remaining_time;
struct tm eta_tm_buf;
struct tm *eta_tm = localtime_r(&eta_time, &eta_tm_buf);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line between definition and code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants