i was playing around with POSIX qw{strftime};
to use as uptime for a program and i found something i didn't know why it happend. I don't use time that much, this was the reason i was messing with it (learning to fill "time" :P)
the math gives me | uptime: 01:00:00
where i should be 00:00:00
I put in the line
$stop_secs = $stop_secs - "3600";
and "fixed" it, but I wonder where that extra hour came from.
i have no clue why, can anyone explain this or why this happens? thanks.
#!/usr/bin/perl
#
use strict;
use warnings;
use POSIX qw{strftime};
my $start_secs = time();
my $start_time = strftime '%H:%M:%S', localtime $start_secs; # all is: "%Y-%m-%d %H:%M:%S"
my $stop_secs = time();
$stop_secs = $stop_secs - "3600"; #<--- this fix the 1h "bug"?
my $diff_secs = $stop_secs - $start_secs;
my $diff_time = strftime '%H:%M:%S', localtime $diff_secs;
print "
| Time started: $start_time
| uptime: $diff_time
\n";