Skip to content

Commit

Permalink
Add helper for building subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
GuiltyDolphin committed Jul 19, 2016
1 parent 1b889f0 commit acae09e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/DDG/Goodie/RandomDate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ handle query => sub {

return if $formatted eq $format;

my $subtitle = build_subtitle(
type => $type,
format => $format,
);

return html_enc("$formatted"),
structured_answer => {

data => {
title => html_enc("$formatted"),
subtitle => $type eq 'format'
? "Random date for: " . html_enc($format) : "Random $type",
title => html_enc("$formatted"),
subtitle => $subtitle,
},

templates => {
Expand All @@ -81,6 +85,15 @@ handle query => sub {
};
};

sub build_subtitle {
my %options = @_;
my $type = $options{type};
my $format = $options{format};
$type eq 'format'
? "Random date for: " . html_enc($format)
: "Random $type";
}

sub format_date {
my ($format, $date, $force_cldr) = @_;
my $formatted;
Expand Down

0 comments on commit acae09e

Please sign in to comment.