Calendar-Persian

 view release on metacpan or  search on metacpan

lib/Calendar/Persian.pm  view on Meta::CPAN

package Calendar::Persian;

$Calendar::Persian::VERSION   = '0.45';
$Calendar::Persian::AUTHORITY = 'cpan:MANWAR';

=head1 NAME

Calendar::Persian - Interface to Persian Calendar.

=head1 VERSION

Version 0.45

=cut

use 5.006;
use Data::Dumper;

use Date::Persian::Simple;
use Moo;
use namespace::autoclean;
with 'Calendar::Plugin::Renderer';

use overload q{""} => 'as_string', fallback => 1;

has year  => (is => 'rw', predicate => 1);
has month => (is => 'rw', predicate => 1);
has date  => (is => 'ro', default   => sub { Date::Persian::Simple->new });

sub BUILD {
    my ($self) = @_;

    $self->date->validate_year($self->year)   if $self->has_year;
    $self->date->validate_month($self->month) if $self->has_month;

    unless ($self->has_year && $self->has_month) {
        $self->year($self->date->year);
        $self->month($self->date->month);
    }
}

=head1 DESCRIPTION

The Persian  calendar  is  solar, with the particularity that the year defined by
two  successive,  apparent  passages    of  the  Sun  through the vernal (spring)
equinox.  It  is based  on precise astronomical observations, and moreover uses a
sophisticated intercalation system, which makes it more accurate than its younger
European  counterpart,the Gregorian calendar. It is currently used in Iran as the
official  calendar  of  the  country. The  starting  point of the current Iranian
calendar is  the  vernal equinox occurred on Friday March 22 of the year A.D. 622.
Persian Calendar for the month of Farvadin year 1390.

    +---------------------------------------------------------------------------------------------------------------+
    |                                             Farvardin   [1394 BE]                                             |
    +---------------+---------------+---------------+---------------+---------------+---------------+---------------+
    |    Yekshanbeh |     Doshanbeh |    Seshhanbeh | Chaharshanbeh |   Panjshanbeh |         Jomeh |       Shanbeh |
    +---------------+---------------+---------------+---------------+---------------+---------------+---------------+
    |                                                                                               |             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 |            31 |                                                                               |
    +---------------+---------------+---------------+---------------+---------------+---------------+---------------+

The package L<App::calendr> provides command line tool  C<calendr> to display the
supported calendars on the terminal.

=head1 SYNOPSIS

    use strict; use warnings;
    use Calendar::Persian;

    # prints current month calendar
    print Calendar::Persian->new, "\n";
    print Calendar::Persian->new->current, "\n";



( run in 1.242 second using v1.01-cache-2.11-cpan-b16cb0d3907 )