Skip to content

Instantly share code, notes, and snippets.

@rstemmer
Created July 26, 2013 14:39
Show Gist options
  • Save rstemmer/6089361 to your computer and use it in GitHub Desktop.
Save rstemmer/6089361 to your computer and use it in GitHub Desktop.
Patches mocp ( http://moc.daper.net/ ) to display huge time-values as HH:MM instead of MMM
diff -upr moc-orig/common.c moc-r2529/common.c
--- moc-orig/common.c 2013-07-26 13:08:11.740070810 +0200
+++ moc-r2529/common.c 2013-07-26 13:29:02.549007274 +0200
@@ -227,9 +227,9 @@ void sec_to_min (char *buff, const int s
{
assert (seconds >= 0);
- if (seconds < 6000) {
+ if (seconds < 60*60) {
- /* the time is less than 99:59 */
+ /* the time is less than 59:59 */
int min, sec;
min = seconds / 60;
@@ -237,10 +237,20 @@ void sec_to_min (char *buff, const int s
snprintf (buff, 6, "%02d:%02d", min, sec);
}
- else if (seconds < 10000 * 60)
+ else if (seconds < 24*60*60) {
- /* the time is less than 9999 minutes */
- snprintf (buff, 6, "%4dm", seconds/60);
+ /* the time is less than 23:59:59 */
+ int hr, min;
+ min = seconds / 60;
+ hr = min / 60;
+ min = min % 60;
+
+ snprintf (buff, 6, "%02d:%02d", hr, min);
+ }
+ else if (seconds < 10000*60*60)
+
+ /* the time is less than 9999 hours */
+ snprintf (buff, 6, "%4dh", seconds/(60*60));
else
strcpy (buff, "!!!!!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment