diff --git a/src/timeinfo.c b/src/timeinfo.c index 9e5288b2..f48d9b78 100644 --- a/src/timeinfo.c +++ b/src/timeinfo.c @@ -235,11 +235,14 @@ void print_format_time(struct text_object *obj, char *p, unsigned int p_max_size if(*currentchar >= '0' && *currentchar <= '9') { asprintf(&temp, "%.*f", (*currentchar) - '0', seconds); } else if(*currentchar == 'x') { - asprintf(&temp, "%.9f", seconds); - while(*(temp + strlen(temp) - 1) == '0' || *(temp + strlen(temp) - 1) == '.') { - *(temp + strlen(temp) - 1) = 0; + if(seconds == (int) seconds ) { + asprintf(&temp, "%d", (int) seconds); + } else { + asprintf(&temp, "%.9f", seconds); + while(*(temp + strlen(temp) - 1) == '0' || *(temp + strlen(temp) - 1) == '.') { + *(temp + strlen(temp) - 1) = 0; + } } - if(*temp == 0) *temp = '0'; }else{ currentchar--; NORM_ERR("$format_time needs a digit behind 'S' to specify precision")