src/chess/rules.c

changeset 107
36dd94278142
parent 105
a991ea61f0e2
equal deleted inserted replaced
106:bdc9528d3e2b 107:36dd94278142
821 used_time += micros / 1000000; 821 used_time += micros / 1000000;
822 822
823 return used_time >= total_time ? 0 : total_time - used_time; 823 return used_time >= total_time ? 0 : total_time - used_time;
824 } 824 }
825 825
826 void print_clk(uint16_t time, char *str, bool always_hours) { 826 int print_clk(uint16_t time, char *str, bool always_hours) {
827 unsigned hours = time / 3600; 827 unsigned hours = time / 3600;
828 unsigned minutes = (time % 3600) / 60; 828 unsigned minutes = (time % 3600) / 60;
829 unsigned seconds = time % 60; 829 unsigned seconds = time % 60;
830 if (hours > 0 || always_hours) { 830 if (hours > 0 || always_hours) {
831 snprintf(str, 9, "%u:%02u:%02u", hours, minutes, seconds); 831 return snprintf(str, 9, "%u:%02u:%02u", hours, minutes, seconds);
832 } else { 832 } else {
833 snprintf(str, 6, "%02u:%02u", minutes, seconds); 833 return snprintf(str, 6, "%02u:%02u", minutes, seconds);
834 } 834 }
835 } 835 }

mercurial