Skip to content

Instantly share code, notes, and snippets.

@axtstar
Created July 12, 2017 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axtstar/b5b480ba2a6d32418897a3b03abedb52 to your computer and use it in GitHub Desktop.
Save axtstar/b5b480ba2a6d32418897a3b03abedb52 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use POSIX;
my $numStr = "";
my $length = @ARGV;
if ($length>0){
$numStr = $ARGV[0];
}
else {
$numStr = <STDIN>;
}
my $hh=0;
my $mm=0;
my $ss=0;
$hh = floor("$numStr" / 3600);
$mm = floor(("$numStr" - "$hh" * 3600) / 60);
$ss = "$numStr" - "$hh" * 3600 - "$mm" * 60;
printf ("%02d:%02d:%02d",$hh,$mm,$ss);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment