]> jfr.im git - irc/quakenet/newserv.git/commitdiff
longtoduration formats 0 and 1 back to how they were.
authorChris Porter <redacted>
Mon, 18 Aug 2008 23:36:16 +0000 (00:36 +0100)
committerChris Porter <redacted>
Mon, 18 Aug 2008 23:36:16 +0000 (00:36 +0100)
control/control.c
lib/irc_string.c

index e13232fb22317ad6944461d42b67a828c1f86a8b..efeddfef51a0a697010aedb7840369414f34a94c 100644 (file)
@@ -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
index dd4b748e5204688f7828fbfacaf71a97c619d992..0359b51b43a34230e312fccaeb704d274db8aa6f 100644 (file)
@@ -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) {