<commit_before>package DDG::Goodie::LeapYear;
# ABSTRACT: Check if a year is leap year
use DDG::Goodie;
use Date::Leapyear;

zci answer_type => "leap_year";

primary_example_queries 'is it a leap year';
secondary_example_queries 'when is the next leap year';
description 'Check if it is a leap year';
name 'Leap year';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/LeapYear.pm';
category 'calculations';
topics 'everyday';
attribution github => [ 'https://github.com/tophattedcoder', '<NAME>'];

triggers startend => 'leap year';
handle remainder => sub {
    my ($second, $minute, $hour, $dayOfMonth, $month, $partyear, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
    my $year = $partyear + 1900; 
    if (index($_, "next") != -1) {
        $year ++;
        while(!isleap($year)) {
            $year ++;
        }
        return "$year is the next leap year";
    } elsif (index($_, "last") != -1) {
        $year --;
        while(!isleap($year)) {
            $year--;
        }
        return "$year was the last leap year";
    } elsif($_ =~ /([0-9]+) ?(ad|bce|bc|ce)?/i) {
        my $cyear = $1;
        my $postfix = $2;
        if(! defined($2) || $postfix =~ /(ce|ad)/i) {
            $postfix = "CE";
        } elsif($postfix =~ /(bce|bc)/i) {
            $postfix = "BCE";
            $cyear = -$cyear;
        }<commit_msg>Support enquring about multiple leap years<commit_after>package DDG::Goodie::LeapYear;
# ABSTRACT: Check if a year is leap year
use DDG::Goodie;
use Date::Leapyear;
use strict;
use warnings;

zci answer_type => "leap_year";

primary_example_queries 'is it a leap year';
secondary_example_queries 'when is the next leap year';
description 'Check if it is a leap year';
name 'Leap year';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/LeapYear.pm';
category 'calculations';
topics 'everyday';
attribution github => [ 'https://github.com/tophattedcoder', '<NAME>'];

triggers startend => 'leap years', 'leap year';
handle remainder => sub {
    my ($second, $minute, $hour, $dayOfMonth, $month, $partyear, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
    my $year = $partyear + 1900;
    if ($_ =~ /(last|previous) ([0-9]?[0-9])/) {
        my @years = ();
        my $numdone = 0;
        $year --;
        while($numdone < $2) {
            while(!isleap($year)) {
                $year--;
            }
            $years[$numdone++] = $year--;
        }
        my @pretty_years = join(', ', @years);
        return "The last $2 leap years were @pretty_years";
    } elsif ($_ =~ /next ([0-9]?[0-9])/) {
        my @years = ();
        my $numdone = 0;
        $year ++;
        while($numdone < $1) {
            while(!isleap($year)) {
                $year++;
            }
            $years[$numdone++] = $year++;
        }
        my @pretty_years = join(', ', @years);
        return "The next $1 leap years are @pretty_years";
    } elsif ($_ =~ /next/) {
        $year ++;
        while(!isleap($year)) {
            $year ++;
        }
        return "$year is the next leap year";
    } elsif ($_ =~ /last|previous/) {
        $year --;
        while(!isleap($year)) {
            $year--;
        }
        return "$year was the last leap year";
    } elsif($_ =~ /([0-9]+) ?(ad|bce|bc|ce)?/i) {
        my $cyear = $1;
        my $postfix = $2;
        if(! defined($2) || $postfix =~ /(ce|ad)/i) {
            $postfix = "CE";
        } elsif($postfix =~ /(bce|bc)/i) {
            $postfix = "BCE";
            $cyear = -$cyear;
        }
{'fraction_non_alphanumeric': 0.1802277145237434, 'fraction_numerical': 0.009441821716189947, 'mean_word_length': 2.307621671258035, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3919567', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1255, 'n_words': 305}