Example code from the application for the Pebble watch. The code works and outputs a timer between two timestamp, but how to make it more beautiful?
char d[5];
char h[5];
char m[5];
char s[5];
const char *start = "START";
time_t now_time = time(NULL);
int tt = other_time - now_time;
if (tt > 0) {
int rest = tt % 31556926;
int dd = rest / 86400;
rest = tt % 86400;
int hh = rest / 3600;
rest = tt % 3600;
int mm = rest / 60;
int ss = rest % 60;
if (dd > 0)
snprintf(d, sizeof(d), "%dD", dd);
else
snprintf(d, sizeof(d), "%s", "\n");
...
if (ss > 0)
snprintf(s, sizeof(s), " %dS", ss);
else
snprintf(s, sizeof(s), "%s", "\n");
snprintf(string, sizeof(string), "%s%s%s%s", d, h, m, s);
} else {
snprintf(string, sizeof(string), "%s", start);
}