mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-24 15:15:44 +00:00
Avoid extremely large year values when printing time
This commit is contained in:
parent
b83ce85d89
commit
ec809b7f71
@ -211,7 +211,12 @@ void Process_printTime(RichString* str, unsigned long long totalHundredths, bool
|
||||
int years = days / 365;
|
||||
int daysLeft = days - 365 * years;
|
||||
|
||||
if (daysLeft >= 100) {
|
||||
if (years >= 10000000) {
|
||||
RichString_appendnAscii(str, yearColor, "eternity ", 9);
|
||||
} else if (years >= 1000) {
|
||||
len = xSnprintf(buffer, sizeof(buffer), "%7dy ", years);
|
||||
RichString_appendnAscii(str, yearColor, buffer, len);
|
||||
} else if (daysLeft >= 100) {
|
||||
len = xSnprintf(buffer, sizeof(buffer), "%3dy", years);
|
||||
RichString_appendnAscii(str, yearColor, buffer, len);
|
||||
len = xSnprintf(buffer, sizeof(buffer), "%3dd ", daysLeft);
|
||||
|
Loading…
Reference in New Issue
Block a user