mirror of https://github.com/moparisthebest/curl
made time2str() use longs internally instead to prevent compiler warnings
when converting to ints
This commit is contained in:
parent
1c652dfc5d
commit
306ff5649a
|
@ -42,24 +42,24 @@
|
||||||
byte) */
|
byte) */
|
||||||
static void time2str(char *r, long t)
|
static void time2str(char *r, long t)
|
||||||
{
|
{
|
||||||
int h;
|
long h;
|
||||||
if(!t) {
|
if(!t) {
|
||||||
strcpy(r, "--:--:--");
|
strcpy(r, "--:--:--");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
h = (t/3600);
|
h = (t/3600);
|
||||||
if(h <= 99) {
|
if(h <= 99) {
|
||||||
int m = (t-(h*3600))/60;
|
long m = (t-(h*3600))/60;
|
||||||
int s = (t-(h*3600)-(m*60));
|
long s = (t-(h*3600)-(m*60));
|
||||||
sprintf(r, "%2d:%02d:%02d",h,m,s);
|
sprintf(r, "%2ld:%02ld:%02ld",h,m,s);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* this equals to more than 99 hours, switch to a more suitable output
|
/* this equals to more than 99 hours, switch to a more suitable output
|
||||||
format to fit within the limits. */
|
format to fit within the limits. */
|
||||||
if(h/24 <= 999)
|
if(h/24 <= 999)
|
||||||
sprintf(r, "%3dd %02dh", h/24, h-(h/24)*24);
|
sprintf(r, "%3ldd %02ldh", h/24, h-(h/24)*24);
|
||||||
else
|
else
|
||||||
sprintf(r, "%7dd", h/24);
|
sprintf(r, "%7ldd", h/24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue