package Common::Date::Quarter;

use base 'Common::Date';

sub priority { 750 }
sub type     { 'quarter' }

sub _patterns {
    [
        #q1 2008 | 1q 2008 | 20081q | 2008q1 | Q4-11
        new Common::Date::Pattern( pattern => '(\d{4})\s*q([1234])', month => 2, year => 1 ),
        new Common::Date::Pattern( pattern => '(\d{4})\s*([1234])q', month => 2, year => 1 ),
        new Common::Date::Pattern( pattern => '([1234])q\s*(\d{4})', month => 1, year => 2 ),
        new Common::Date::Pattern( pattern => 'q([1234])\s*(\d{4})', month => 1, year => 2 ),
        new Common::Date::Pattern( pattern => 'Q([1234])-(\d{4})',   month => 1, year => 2 ),
    ];
}

sub month {
    my $self = shift;

    my $endMonth = $self->{_month} * 3;

    return $endMonth - 2;
}

1;
