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;
die "No configuration file found\n" unless $config;
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;
}
use Test::More tests => 2;
BEGIN { use_ok('App::Lastmsg') };
-my $real_strftime = \&POSIX::strftime;
-
{
no warnings 'redefine';
- *App::Lastmsg::strftime = sub {
- my ($format, @rest) = @_;
- $real_strftime->('%s', @rest)
- };
+ *App::Lastmsg::format_time = sub { shift };
}
chdir 't';