Calendar-Bahai

 view release on metacpan or  search on metacpan

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

package Calendar::Bahai;

$Calendar::Bahai::VERSION   = '0.56';
$Calendar::Bahai::AUTHORITY = 'cpan:MANWAR';

=head1 NAME

Calendar::Bahai - Interface to the calendar used by Bahai faith.

=head1 VERSION

Version 0.56

=cut

use 5.006;
use Data::Dumper;

use Date::Bahai::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::Bahai::Simple->new });

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

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

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

=head1 DESCRIPTION

The  Bahai  calendar started from the original Badi calendar, created by the Bab.
The  Bahai  calendar  is  composed  of 19 months, each with 19 days. Years in the
Bahai  calendar  are  counted  from Thursday, 21 March 1844, the beginning of the
Bahai  Era  or Badi Era (abbreviated BE or B.E.). Year 1 BE thus began at sundown
20  March  1844.  Using the Bahai names for the weekday and month, day one of the
Bahai Era was Istijlal (Majesty), 1 Baha (Splendour) 1 BE.

   +----------------------------------------------------------------------------+
   |                             Baha      [172 BE]                             |
   +----------+----------+----------+----------+----------+----------+----------+
   |    Jamal |    Kamal |    Fidal |     Idal | Istijlal | Istiqlal |    Jalal |
   +----------+----------+----------+----------+----------+----------+----------+
   |                                                                 |        1 |
   +----------+----------+----------+----------+----------+----------+----------+
   |        2 |        3 |        4 |        5 |        6 |        7 |        8 |
   +----------+----------+----------+----------+----------+----------+----------+
   |        9 |       10 |       11 |       12 |       13 |       14 |       15 |
   +----------+----------+----------+----------+----------+----------+----------+
   |       16 |       17 |       18 |       19 |                                |
   +----------+----------+----------+----------+----------+----------+----------+

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::Bahai;

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

    # prints bahai month calendar for the first month of year 172.
    print Calendar::Bahai->new({ month => 1, year => 172 }), "\n";

    # prints bahai month calendar in which the given gregorian date falls in.
    print Calendar::Bahai->new->from_gregorian(2015, 1, 14), "\n";



( run in 2.480 seconds using v1.01-cache-2.11-cpan-aadc1410aed )