Advertisement
Guest User

kspconverttime

a guest
Jul 8th, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. $a=scalar(@ARGV);
  4. for ($i=0;$i<4;$i++) {$t[$i]=0;}
  5. for ($i=0;$i<$a;$i++) {
  6. $t[$a-1-$i]=$ARGV[$i];
  7. }
  8.  
  9. $t=$t[0]+$t[1]*60+$t[2]*3600+$t[3]*6*3600;
  10.  
  11. if ($a==1) {
  12. $s=$t%60; $t/=60;
  13. $m=$t%60; $t/=60;
  14. $h=$t%6; $t/=6;
  15. $d=$t;
  16.  
  17. printf "%dd %d:%d:%d\n",$d,$h,$m,$s;
  18. } else {
  19. printf "%d\n",$t;
  20. }
  21.  
  22. #bernhard@b:~/src$ ./kspconverttime 1 1 0 0
  23. #25200
  24. #bernhard@b:~/src$ ./kspconverttime 25200
  25. #1d 1:0:0
  26. #echo `./kspconverttime 10 43 17`-`./kspconverttime 3 40 0`|bc|./kspconverttime `cat /proc/self/fd/0`
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement