From: Chris Porter Date: Mon, 18 Aug 2008 23:36:16 +0000 (+0100) Subject: longtoduration formats 0 and 1 back to how they were. X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/commitdiff_plain/632227f54b03bf5e82c921386cf81a214156f209 longtoduration formats 0 and 1 back to how they were. --- diff --git a/control/control.c b/control/control.c index e13232fb..efeddfef 100644 --- a/control/control.c +++ b/control/control.c @@ -1,4 +1,4 @@ -#/* +/* * This is the first client module for newserv :) * * A very simple bot which should give people some ideas for how to diff --git a/lib/irc_string.c b/lib/irc_string.c index dd4b748e..0359b51b 100644 --- a/lib/irc_string.c +++ b/lib/irc_string.c @@ -232,7 +232,9 @@ const char *IPlongtostr(unsigned long IP) { /* * longtoduration: * Converts a specified number of seconds into a duration string. - * format: 0 for the "/stats u" compatible output, 1 for more human-friendly output, 2 for a different human-friendly output. + * format: 0 for the "/stats u" compatible output, 1 for more + * human-friendly output (that is sometimes format 0), and + * 2 for a different human-friendly output. */ const char *longtoduration(unsigned long interval, int format) { @@ -245,11 +247,11 @@ const char *longtoduration(unsigned long interval, int format) { hours=(interval%(3600*24))/3600; days=interval/(3600*24); - if (format==0) { - sprintf(outstring,"%d day%s, %02d:%02d:%02d", - days,(days==1)?"":"s",hours,minutes,seconds); - } else if (format == 1) { - if (days>0) { + if(format<2) { + if (format==0 || (days>0 && (hours||minutes||seconds))) { + sprintf(outstring,"%d day%s, %02d:%02d:%02d", + days,(days==1)?"":"s",hours,minutes,seconds); + } else if (days>0) { sprintf(outstring, "%d day%s",days,(days==1)?"":"s"); } else { if (hours>0) {