Skip to content

Commit

Permalink
clean up un formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yegg committed May 9, 2012
1 parent 49a46c4 commit e2aad5a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/DDG/Goodie/ParseCron.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ handle remainder => sub {
my $cron = new Schedule::Cron::Events($crontab) or return;
my ($sec, $min, $hour, $day, $month, $year) = $cron->nextEvent;
$year = $year+1900;
my $text = sprintf qq(Cron will start this event next at %02d:%02d:%02d on %d %s, %d), $hour, $min, $sec, $day, $mon[$month], $year . '.';
my $text = sprintf qq(Cron will start this event next at %02d:%02d:%02d on %d %s, %d), $hour, $min, $sec, $day, $mon[$month], $year;
$text .= '.';
return $text if $_;
return;
};
Expand Down
3 changes: 2 additions & 1 deletion lib/DDG/Goodie/UN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ zci answer_type => 'united_nations';
handle remainder => sub {
my $num = shift or return;
my %un = get_un($num) or return;
return (sprintf qq(%s (UN Number %04d)), $un{description}, $num), html => sprintf qq(%s (<a href="%s">UN Number %04d</a>)), $un{description}, wphref($num), $num;
$un{description} =~ s/\.$//;
return (sprintf qq(UN Number %04d - %s.), $num, $un{description}), html => sprintf qq(<a href="%s">UN Number %04d</a> - %s.), wphref($num), $num, $un{description};
};

# Wikipedia attribution per CC-BY-SA
Expand Down
4 changes: 2 additions & 2 deletions t/ParseCron.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ ddg_goodie_test(
[qw(
DDG::Goodie::ParseCron
)],
'crontab * */3 * * *' => test_zci(qr/^Event will start next at \d{2}:\d{2}:\d{2} on \d{1,2} [a-zA-Z]{3}, \d{4}$/),
'crontab 42 12 3 Feb Sat' => test_zci(qr/^Event will start next at \d{2}:\d{2}:\d{2} on \d{1,2} [a-zA-Z]{3}, \d{4}$/),
'crontab * */3 * * *' => test_zci(qr/^Cron will start this event next at \d{2}:\d{2}:\d{2} on \d{1,2} [a-zA-Z]{3}, \d{4}\.$/),
'crontab 42 12 3 Feb Sat' => test_zci(qr/^Cron will start this event next at \d{2}:\d{2}:\d{2} on \d{1,2} [a-zA-Z]{3}, \d{4}\.$/),
);

done_testing;
Expand Down
4 changes: 2 additions & 2 deletions t/UN.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ddg_goodie_test(
[qw(
DDG::Goodie::UN
)],
'un 9' => test_zci('Ammunition, incendiary with or without burster, expelling charge, or propelling charge (UN Number 0009)', html => 'Ammunition, incendiary with or without burster, expelling charge, or propelling charge (<a href="http://en.wikipedia.org/wiki/List_of_UN_numbers_0001_to_0100">UN Number 0009</a>)', answer_type => "united_nations"),
'un 1993' => test_zci('Combustible liquids, n.o.s. (UN Number 1993)', html => 'Combustible liquids, n.o.s. (<a href="http://en.wikipedia.org/wiki/List_of_UN_numbers_1901_to_2000">UN Number 1993</a>)', answer_type => "united_nations"),
'un 9' => test_zci('UN Number 0009 - Ammunition, incendiary with or without burster, expelling charge, or propelling charge.', html => '<a href="http://en.wikipedia.org/wiki/List_of_UN_numbers_0001_to_0100">UN Number 0009</a> - Ammunition, incendiary with or without burster, expelling charge, or propelling charge.', answer_type => "united_nations"),
'un 1993' => test_zci('UN Number 1993 - Combustible liquids, n.o.s.', html => '<a href="http://en.wikipedia.org/wiki/List_of_UN_numbers_1901_to_2000">UN Number 1993</a> - Combustible liquids, n.o.s.', answer_type => "united_nations"),

);

Expand Down

0 comments on commit e2aad5a

Please sign in to comment.