Convert the Hijri package to a generic Calendar package

master
Ehsan Akhgari 2014-08-09 21:19:16 -04:00 committed by Matt Miller
parent 1a7a4af612
commit e5e13c30fc
2 changed files with 8 additions and 9 deletions

View File

@ -1,5 +1,5 @@
package DDG::Goodie::Hijri;
# ABSTRACT: convert between Gregorian and Hiriji calendars.
package DDG::Goodie::CalendarConversion;
# ABSTRACT: convert between various calendars.
use DDG::Goodie;
@ -9,8 +9,8 @@ zci answer_type => "conversion";
primary_example_queries '22/8/2003 to the hijri calendar';
secondary_example_queries '23/6/1424 to gregorian';
description 'convert dates from the Gregorian calendar to the Hijri calendar and back';
name 'Hijri';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Hijri.pm';
name 'CalendarConversion';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/CalendarConversion.pm';
category 'dates';
topics 'special_interest';
attribution github => [ 'http://github.com/mattlehning', 'mattlehning' ];
@ -30,12 +30,12 @@ sub output {
}
handle query_lc => sub {
return unless my ($gd, $gm, $gy, $requested_calendar) = $_ =~
return unless my ($gd, $gm, $gy, $input_calendar, $output_calendar) = $_ =~
/^
(\d{0,2})(?:\/|,)(\d{0,2})(?:\/|,)(\d{3,4})\s+
(?:
(?:on\s+the)\s+
(?:gregorian|hijri)\s+
((?:gregorian|hijri)?)\s+
(?:calendar|date|time)\s+
is\s+
)?
@ -48,7 +48,7 @@ handle query_lc => sub {
return unless ($gd < 31 and $gm < 12);
my $is_hijri = $requested_calendar eq 'hijri';
my $is_hijri = $output_calendar eq 'hijri';
my ($hd, $hm, $hy) = $is_hijri ? g2h($gd, $gm, $gy) : h2g($gd, $gm, $gy);
my $input_date = "$gd/$gm/$gy";

View File

@ -4,13 +4,12 @@ use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
use Date::Hijri;
zci answer_type => 'conversion';
zci is_cached => 0;
ddg_goodie_test(
[qw(DDG::Goodie::Hijri)],
[qw(DDG::Goodie::CalendarConversion)],
'22/8/2003 to hijri' => test_zci(
'22/8/2003 on the Gregorian calendar is 23/6/1424 on the Hijri calendar.',
html => '22/8/2003 on the '