show proper values for very large times

This commit is contained in:
Hisham Muhammad 2011-12-14 23:29:07 +00:00
parent 0bb8dba937
commit 9c44f589d2
1 changed files with 11 additions and 6 deletions

View File

@ -312,13 +312,17 @@ static void Process_printTime(RichString* str, unsigned long long t) {
double realTime = t * jiffytime; double realTime = t * jiffytime;
int iRealTime = (int) realTime; int iRealTime = (int) realTime;
int hours = iRealTime / 3600; unsigned long long hours = iRealTime / 3600;
int minutes = (iRealTime / 60) % 60; int minutes = (iRealTime / 60) % 60;
int seconds = iRealTime % 60; int seconds = iRealTime % 60;
int hundredths = (realTime - iRealTime) * 100; int hundredths = (realTime - iRealTime) * 100;
char buffer[11]; char buffer[11];
if (hours >= 100) {
snprintf(buffer, 10, "%7lluh ", hours);
RichString_append(str, CRT_colors[LARGE_NUMBER], buffer);
} else {
if (hours) { if (hours) {
snprintf(buffer, 10, "%2dh", hours); snprintf(buffer, 10, "%2lluh", hours);
RichString_append(str, CRT_colors[LARGE_NUMBER], buffer); RichString_append(str, CRT_colors[LARGE_NUMBER], buffer);
snprintf(buffer, 10, "%02d:%02d ", minutes, seconds); snprintf(buffer, 10, "%02d:%02d ", minutes, seconds);
} else { } else {
@ -326,6 +330,7 @@ static void Process_printTime(RichString* str, unsigned long long t) {
} }
RichString_append(str, CRT_colors[DEFAULT_COLOR], buffer); RichString_append(str, CRT_colors[DEFAULT_COLOR], buffer);
} }
}
static inline void Process_writeCommand(Process* this, int attr, int baseattr, RichString* str) { static inline void Process_writeCommand(Process* this, int attr, int baseattr, RichString* str) {
int start = RichString_size(str); int start = RichString_size(str);