Prep for 0.9.3 release.
[stopish] / src / timer.c
index 42f65d5..fe42c75 100644 (file)
@@ -1,6 +1,6 @@
 //      timer.c
 //
-//      Copyright 2009 Michael Cronenworth <mike@cchtml.com>
+//      Copyright 2010 Michael Cronenworth <mike@cchtml.com>
 //
 //      This program is free software; you can redistribute it and/or modify
 //      it under the terms of the GNU General Public License as published by
@@ -60,13 +60,26 @@ char *stopish_get_time_string( void )
         h = m = s = ss = 0;
     }
 
+    if ( stopish_get_type(  ) == STOPISH_TYPE_COUNTDOWN ) {
+        h = -h;
+        m = -m;
+        s = -s;
+        ss = -ss;
+    }
+    // countdown check
+    if ( stopish_get_type(  ) == STOPISH_TYPE_COUNTDOWN &&
+         ( h == 0 && m == 0 && s == 0 && ss == 0 ) )
+        return NULL;
+
     timeBuffer = malloc( 64 );
     if ( timerPrecision == TIMER_PRECISION_MINUTE )
         sprintf( timeBuffer, "%.02d:%.02d.%.1d",
-                 m, s, ss );
+                 ( unsigned int ) m, ( unsigned int ) s,
+                 ( unsigned int ) ss );
     else
         sprintf( timeBuffer, "%.02d:%.02d:%.02d.%.1d",
-                 h, m, s, ss );
+                 ( unsigned int ) h, ( unsigned int ) m,
+                 ( unsigned int ) s, ( unsigned int ) ss );
 
     return timeBuffer;
 }