summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepoch <epoch@hack.thebackupbox.net>2021-08-03 03:45:56 +0000
committerepoch <epoch@hack.thebackupbox.net>2021-08-03 03:45:56 +0000
commit8f570ffd199b54c05156108d7a3bcdeb203fb890 (patch)
treebd3bc701e46706383bd56d796d8a391e1aac648c
parent0bd04927337c4c7064b9a881099358d024bd280c (diff)
downloadmisc-8f570ffd199b54c05156108d7a3bcdeb203fb890.tar.gz
misc-8f570ffd199b54c05156108d7a3bcdeb203fb890.zip
short output also shows hour now
-rw-r--r--src/bin/elapsedtime.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bin/elapsedtime.c b/src/bin/elapsedtime.c
index 6f30429..bb91d99 100644
--- a/src/bin/elapsedtime.c
+++ b/src/bin/elapsedtime.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <string.h> //strcmp, strchr
#include <stdlib.h>
int main(int argc,char *argv[]) {
@@ -17,7 +18,11 @@ int main(int argc,char *argv[]) {
char *f=strchr(*argv,'.');
ll=atoll(*argv);
if(s) {
- printf("%lld:%02lld%s\n",ll / 60 % 60,ll % 60,f?f:"");
+ if(ll / 3600) {
+ printf("%lld:%lld:%02lld%s\n",ll / 3600, ll / 60 % 60,ll % 60,f?f:"");
+ } else {
+ printf("%lld:%02lld%s\n",ll / 60 % 60,ll % 60,f?f:"");
+ }
return 0;
}
if(ll / 31557600 ) { if(c) printf(", ");c=1;printf("%lld year%s", ll / 31557600, ll / 31557600 == 1 ? "" : "s"); }