]> iEval git - app-lastmsg.git/blobdiff - lib/App/Lastmsg.pm
Make tests pass on systems without %s strftime specifier
[app-lastmsg.git] / lib / App / Lastmsg.pm
index ca69e6dde6569828d4bedc31c03a689e1bf7c35f..8d2cce57eb09d247c336dcd61711c9ed32a58d0d 100644 (file)
@@ -12,12 +12,13 @@ use List::Util qw/max/;
 use POSIX qw/strftime/;
 
 our $OUTPUT_FILEHANDLE = \*STDOUT;
-our $VERSION = '0.001001';
+our $VERSION = '0.001002';
 
-our @DEFAULT_INBOX = (
-       "/var/mail/$ENV{USER}",
-       "$ENV{HOME}/Maildir/",
-);
+our @DEFAULT_INBOX;
+push @DEFAULT_INBOX, "/var/mail/$ENV{USER}" if exists $ENV{USER};
+push @DEFAULT_INBOX, "$ENV{HOME}/Maildir"   if exists $ENV{HOME};
+
+sub format_time { strftime '%c', localtime shift }
 
 sub run {
        my $config = Config::Auto->new(format => 'yaml')->parse;
@@ -95,7 +96,7 @@ sub run {
        my $addrlen = max map { length } values %lastaddr;
 
        for (sort { $lastmsg{$b} <=> $lastmsg{$a} } keys %lastmsg) {
-               my $time = strftime '%c', localtime $lastmsg{$_};
+               my $time = format_time $lastmsg{$_};
                printf $OUTPUT_FILEHANDLE "%-${idlen}s %-${addrlen}s %s\n", $_, $lastaddr{$_}, $time;
        }
 
This page took 0.021226 seconds and 4 git commands to generate.