#!/usr/bin/env perl use strict; use warnings; use Test::More; use DDG::Test::Goodie; use Test::MockTime qw( :all ); zci answer_type => 'calendar'; zci is_cached => 0; ddg_goodie_test( [qw( DDG::Goodie::CalendarToday )], 'calendar' => test_zci(qr/\nS M T W T F S[ ]+[A-Za-z]+ [0-9]{4}\n.+/, html => qr##), 'calendar november' => test_zci(qr/\nS M T W T F S November [0-9]{4}\n.+/, html => qr#
#), 'calendar november 12th' => test_zci(qr/\nS M T W T F S November [0-9]{4}\n.+/, html => qr#
#), 'calendar last november' => test_zci(qr/\nS M T W T F S November [0-9]{4}\n.+/, html => qr#
#), 'calendar next november' => test_zci(qr/\nS M T W T F S November [0-9]{4}\n.+/, html => qr#
#), 'calendar november 2009' => test_zci(" S M T W T F S November 2009 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ", html => qr#
November 2009
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
2930
#), 'calendar nov 2009' => test_zci(" S M T W T F S November 2009 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ", html => qr#
November 2009
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
2930
#), 'calendar 29 nov 2015' => test_zci(" S M T W T F S November 2015 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |29| 30 ", html => qr#
November 2015
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
2930
#), 'calendar 29.11.2015' => test_zci(" S M T W T F S November 2015 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |29| 30 ", html => qr#
November 2015
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
2930
#), 'cal 1980-11-29' => test_zci(" S M T W T F S November 1980 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |29| 30 ", html => qr#
November 1980
SMTWTFS
      1
2345678
9101112131415
16171819202122
23242526272829
30
#), 'calendar for november 2009' => test_zci(" S M T W T F S November 2009 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ", html => qr#
November 2009
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
2930
#), 'next november on a calendar' => test_zci(qr/\nS M T W T F S November [0-9]{4}\n.+/, html => qr##), 'calendar for november' => test_zci(qr/\nS M T W T F S November [0-9]{4}\n.+/, html => qr#
#), 'calendar of november 2009' => test_zci(" S M T W T F S November 2009 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ", html => qr#
November 2009
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
2930
#), '22/8/2003 to the hijri calendar' => undef, "today's calendar" => test_zci(qr/\nS M T W T F S [A-Z][a-z]+ [0-9]{4}\n.+/, html => '-ANY-'), "november's calendar" => test_zci(qr/\nS M T W T F S November [0-9]{4}\n.+/, html => '-ANY-'), ); # Special focus on relative dates, examining the "today" circle my $test_location_tz = qr/\(EDT, UTC-4\)/; set_fixed_time("2014-06-11T09:45:56"); ddg_goodie_test( [qw( DDG::Goodie::CalendarToday )], "calendar yesterday" => test_zci(qr/June 2014.*\|10\|/s, html => qr#10#), "calendar today" => test_zci(qr/June 2014.*\|11\|/s, html => qr#11#), "calendar tomorrow" => test_zci(qr/June 2014.*\|12\|/s, html => qr#12#), "calendar 20 days ago" => test_zci(qr/May 2014.*\|22\|/s, html => qr#22#), "calendar in 20 days" => test_zci(qr/July 2014.*\| 1\|/s, html => qr#1#), "calendar last week" => test_zci(qr/June 2014.*\| 4\|/s, html => qr#4#), "calendar next week" => test_zci(qr/June 2014.*\|18\|/s, html => qr#18#), "calendar last year" => test_zci(qr/June 2013.*\|11\|/s, html => qr#11#), "calendar next year" => test_zci(qr/June 2015.*\|11\|/s, html => qr#11#), ); restore_time(); done_testing;