diff options
author | Joe Robinson <joe@lc8n.com> | 2017-07-12 14:23:57 +0100 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2017-07-12 14:23:57 +0100 |
commit | 1a5f471f587b3be5c732cca2f94ec5cfa9bfa108 (patch) | |
tree | 11c98950644b8e802b81dbb0ebf786bd636d1f07 | |
parent | a46542b43eb800d3d807e1ce6c1e15482a113684 (diff) |
Add comments
-rwxr-xr-x | unixtime.pl | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/unixtime.pl b/unixtime.pl index d6bb1d8..2675634 100755 --- a/unixtime.pl +++ b/unixtime.pl @@ -4,18 +4,22 @@ use Time::HiRes qw( gettimeofday ); if (defined $ARGV[0]) { if ($ARGV[1] eq "ms") { + #Convert from timestamp in milliseconds to date $seconds = substr $ARGV[0], 0, 10; $milliseconds = substr $ARGV[0], 10, 3; $date = strftime('%a %b %e %H:%M:%S:'.$milliseconds.' %Z %Y', localtime( $seconds ) ) . "\n"; print $date; } elsif ($ARGV[0] eq "ms") { + #Print current millisecond unix timestamp ($seconds, $microseconds) = gettimeofday; $milliseconds = substr $microseconds, 0, 3; print $seconds . $milliseconds . "\n"; } else { + #Convert standard unix timestamp to date print strftime('%a %b %e %H:%M:%S %Z %Y', localtime( $ARGV[0] ) ) . "\n"; } } else { + #Print current standard unix timestamp print time . "\n"; } |