Calendar-Bahai

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.37  Sun Sep 25 19:40:00 2016
      - Added key 'provides' to the Makefile.PL script.

0.36  Wed Aug 10 11:30:00 2016
      - Updated dependency on Date::Bahai::Simple v0.15.

0.35  Fri Jul 08 15:00:00 2016
      - Added method as_text().
      - Updated method as_svg() with regard to start index.
      - Added dependency on Calendar::Plugin::Renderer v0.07.
      - Added test for method svg_calendar().

0.34  Fri May 13 11:40:00 2016
      - Updated dependency on Date::Bahai::Simple v0.13.
      - Tidied up method current() and method from_gregorian().
      - Updated method as_svg() to make use of method get_month_number() and method get_month_name().
      - Updated pod document with regard to the Calendar::Plugin::Renderer v0.06.
      - Added section "SEE ALSO".
      - Updated copyright year information.

0.33  Sat Jan 09 02:30:00 2016

Changes  view on Meta::CPAN

      - Updated pod for method as_svg().

0.29  Fri Dec 18 20:35:00 2015
      - Added method as_svg() using the plugin Calendar::Plugin::Renderer.

0.28  Fri Aug 28 10:45:00 2015
      - Upgraded to use Date::Bahai::Simple v0.11.

0.27  Wed Jul 15 10:05:00 2015
      - Upgraded to use Date::Bahai::Simple v0.10.
      - Making use of the method get_calendar() provided by Date::Bahai::Simple.

0.26  Tue Jul 07 10:10:00 2015
      - Upgraded to use Date::Bahai::Simple v0.09.

0.25  Sat Jun 27 16:40:00 2015
      - Upgraded to use Date::Bahai::Simple v0.08.

0.24  Wed Jun 17 18:15:00 2015
      - Fixed the bug in the method from_gregorian().

0.23  Mon Jun 08 11:40:00 2015
      - Updated method _calendar() to validates month and year.

0.22  Mon May 25 02:05:00 2015
      - Fine tuned method from_gregorian().
      - Fine tuned method from_julian().
      - Dropped un-used method _date().
      - Updated method _calendar() w.r.t the dropped method _date().
      - Removed the code from the pod document for method current().
      - Removed the code from the pod document for method from_gregorian().

0.21  Sun May 24 22:00:00 2015
      - Removed the dependency on Date::Utils::Bahai.
      - Upgraded to use Date::Bahai::Simple v0.04 to fix RT: 103403.

0.20  Sun May 17 00:50:00 2015
      - Upgraded to use Date::Utils::Bahai v0.02.

0.19  Thu Apr 23 23:35:00 2015
      - Re-structured and consumed Date::Utils::Bahai as Moo Role.

0.18  Tue Apr 21 13:45:00 2015
      - Fixed the bug in the method _calendar() the last cell is empty.

0.17  Sun Apr 19 02:45:00 2015
      - Fixed the bug in the method _calendar() when the first day of the month is Sunday.

0.16  Sat Apr 18 02:20:00 2015
      - Removed Date::Bahai and replaced with Date::Bahai::Simple.
      - Moved calendar generation code out of Date::Utils.

0.15  Fri Apr 17 16:00:00 2015
      - Restructured the distribution to make use of new packages Date::Utils
        and Date::Bahai.

0.14  Fri Apr 17 14:50:00 2015
      - Made default month as current bahai month.
      - Documented CONSTRUCTOR in the pod document.
      - Added more code to the section SYNOPSIS.

0.13  Fri Apr 17 12:00:00 2015
      - Cleaned up method Calendar::Bahai::BUILD() and removed duplicate code.
      - Cleaned up method Calendar::Bahai::current() and removed duplicate code.
      - Updated pod description of the following methods in the package Calendar::Bahai:
        - from_gregorian()
        - from_julian()
      - Tidied up method Calendar::Bahai::_calendar() and extracted out common code
        to the get_bahai_month_calendar() in the package Calendar::Bahai::Utils.
      - Renamed method validate_year() to validate_bahai_year()
      - Renamed method validate_month() to validate_bahai_month()
      - Renamed method validate_day() to validate_bahai_day()
      - Enabled method validate_bahai_month()
      - Added the following methods to the package Calendar::Bahai::Utils:
        - bahai_to_gregorian()
        - bahai_to_julian()
        - get_bahai_month_calendar()
      - Updated pod description of the following methods in the package Calendar::Bahai::Utils:
        - gregorian_to_bahai()
        - julian_to_bahai()
        - julian_t0_gregorian()
        - get_major_cycle_year()

0.12  Thu Apr 16 16:50:00 2015
      - Complete re-write of the entire distribution using Moo with unit tests.

0.11  Fri Mar 20 10:30:00 2015

MANIFEST  view on Meta::CPAN

Changes
LICENSE
MANIFEST
MANIFEST.SKIP
Makefile.PL
README
lib/Calendar/Bahai.pm
t/00-load.t
t/calendar-bahai.t
t/bahai.xml
t/fake-bahai.xml
xt/manifest.t
xt/pod.t
xt/meta-json.t
xt/meta-yml.t
META.yml                                 Module YAML meta-data (added by MakeMaker)
META.json                                Module JSON meta-data (added by MakeMaker)

META.json  view on Meta::CPAN

{
   "abstract" : "Interface to the calendar used by Bahai faith.",
   "author" : [
      "Mohammad S Anwar <mohammad.anwar@yahoo.com>"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "artistic_2"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Interface to the calendar used by Bahai faith.'
author:
  - 'Mohammad S Anwar <mohammad.anwar@yahoo.com>'
build_requires:
  File::Temp: '0'
  Test::More: '0'
  XML::SemanticDiff: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010'

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;

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

    $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";

    # prints bahai month calendar in which the given julian date falls in.
    print Calendar::Bahai->new->from_julian(2457102.5), "\n";

    # prints current month bahai calendar in SVG format.
    print Calendar::Bahai->new->as_svg;

    # prints current month bahai calendar in text format.
    print Calendar::Bahai->new->as_text;

=head1 BAHAI MONTHS

    +-------+-------------+----------------+------------------------------------+
    | Month | Arabic Name | English Name   | Gregorian Dates                    |
    +-------+-------------+----------------+------------------------------------+
    | 1     | Baha        | Splendour      | 21 Mar - 08 Apr                    |
    | 2     | Jalal       | Glory          | 09 Apr - 27 Apr                    |
    | 3     | Jamal       | Beauty         | 28 Apr - 16 May                    |

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

    | Kamal       | Perfection   | Monday                                       |
    | Fidal       | Grace        | Tuesday                                      |
    | Idal        | Justice      | Wednesday                                    |
    | Istijlal    | Majesty      | Thursday                                     |
    | Istiqlal    | Independence | Friday                                       |
    | Jalal       | Glory        | Saturday                                     |
    +-------------+--------------+----------------------------------------------+

=head1 KULL-i-SHAY / VAHID

Also  existing in the Bahai calendar system is a 19-year cycle called Vahid and a
361-year (19x19) supercycle called Kull-i-Shay (literally, "All Things"). Each of
the 19 years in a Vahid has been given a name as shown in the table below.The 9th
Vahid of the 1st Kull-i-Shay  started  on 21 March 1996,  and the 10th Vahid will
begin in 2015. The current Bahai year,year 168 BE (21 March 2011 - 20 March 2012)
,  is year Badi of the 9th Vahid of the 1st Kull-i-Shay. The 2nd Kull-i-Shay will
begin in 2205.

=head2 1st Kull-i-Shay

    +----+--------+---------------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+

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

    | 15 | Vidad  | Affection     | 1858 | 1877 | 1896 | 1915 | 1934 | 1953 | 1972 | 1991 | 2010 | 2029 | 2048 | 2067 | 2086 | 2105 | 2124 | 2143 | 2162 | 2181 | 2200 |
    | 16 | Badi   | Beginning     | 1859 | 1878 | 1897 | 1916 | 1935 | 1954 | 1973 | 1992 | 2011 | 2030 | 2049 | 2068 | 2087 | 2106 | 2125 | 2144 | 2163 | 2182 | 2201 |
    | 17 | Bahi   | Luminous      | 1860 | 1879 | 1898 | 1917 | 1936 | 1955 | 1974 | 1993 | 2012 | 2031 | 2050 | 2069 | 2088 | 2107 | 2126 | 2145 | 2164 | 2183 | 2202 |
    | 18 | Abha   | Most Luminous | 1861 | 1880 | 1899 | 1918 | 1937 | 1956 | 1975 | 1994 | 2013 | 2032 | 2051 | 2070 | 2089 | 2108 | 2127 | 2146 | 2165 | 2184 | 2203 |
    | 19 | Vahid  | Unity         | 1862 | 1881 | 1900 | 1919 | 1938 | 1957 | 1976 | 1995 | 2014 | 2033 | 2052 | 2071 | 2090 | 2109 | 2128 | 2147 | 2166 | 2185 | 2204 |
    +----+--------+---------------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+

=head1 NOTE

On July 10, 2014, the  Universal  House  of  Justice  announced  three  decisions
regarding the Badi` (Bahai) calendar,  which  will affect the dates of Feasts and
Holy Days. Naw Ruz will usually fall on March 20th,which means that all the Feast
days will be one day earlier,and the births of the Bab and of Baha'u'llah will be
celebrated on two consecutive days in the Autumn.The changes take effect from the
next Bahai New Year, from sunset on March 20, 2015. The definitive tables showing
the new dates have not yet been released (as of September 24, 2014), but there is
a preliminary discussion L<here|http://senmcglinn.wordpress.com/2014/09/22/changes-in-bahai-calendar-what-how-why>.

=head1 CONSTRUCTOR

It expects month and year  optionally. By default it gets current Bahai month and
year.

=head1 METHODS

=head2 current()

Returns current month of the Bahai calendar.

=cut

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

    return $self->as_text($self->date->month, $self->date->year);
}

=head2 from_gregorian($year, $month, $day)

Returns bahai month calendar in which the given gregorian date falls in.

=cut

sub from_gregorian {
    my ($self, $year, $month, $day) = @_;

    return $self->from_julian($self->date->gregorian_to_julian($year, $month, $day));
}

=head2 from_julian($julian_date)

Returns bahai month calendar in which the given julian date falls in.

=cut

sub from_julian {
    my ($self, $julian_date) = @_;

    my $date = $self->date->from_julian($julian_date);
    return $self->as_text($date->month, $date->year);
}

=head2 as_svg($month, $year)

Returns  calendar  for  the given C<$month> and C<$year> rendered  in SVG format.
C<$month>  can  be  a  number  between  1 and  19 or a valid Bahai month name. If
C<$month> and C<$year> missing, it would return current calendar month.

=cut

sub as_svg {
    my ($self, $month, $year) = @_;

    ($month, $year) = $self->validate_params($month, $year);
    my $date = $self->date->get_date(1, $month, $year);

    return $self->svg_calendar(
        {
            adjust_height => 21,
            start_index   => $date->day_of_week,
            month_name    => $date->get_month_name,
            days          => 19,
            year          => $year
        });
}

=head2 as_text($month, $year)

Returns color coded Bahai calendar for the given C<$month> and C<$year>. C<$month>
can  be  a  number between 1 and 19 or a valid Bahai month name. If C<$month> and
C<$year> missing, it would return current calendar month.

=cut

sub as_text {
    my ($self, $month, $year) = @_;

    ($month, $year) = $self->validate_params($month, $year);
    my $date = $self->date->get_date(1, $month, $year);

    return $self->text_calendar(
        {
            start_index => $date->day_of_week,
            month_name  => $date->get_month_name($month),
            days        => 19,
            day_names   => $date->days,
            year        => $year
        });
}

sub as_string {

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

=item L<Calendar::Hijri>

=item L<Calendar::Persian>

=item L<Calendar::Saka>

=back

=head1 BUGS

Please report any bugs / feature requests to C<bug-calendar-bahai at rt.cpan.org>,
or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Calendar-Bahai>.
I will be notified, and then you'll automatically be notified of progress on your
bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Calendar::Bahai

t/bahai.xml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="297mm" viewBox="0 0 210 297" width="210mm" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
	<g id="calendar" label="Calendar">
		<text fill="blue" id="month" style="font-size: 18.1908" x="22.2412" y="154.4400">Baha</text>
		<text fill="blue" id="year" style="text-align: end; text-anchor: end; font-size: 18.1908" x="201.6000" y="154.4400">172</text>
		<rect height="97.24" id="bounding_box" style="fill:none; stroke: blue; stroke-width: 0.5;" width="179.2" x="22.4" y="160.3800" />
		<g fill="none" id="row0_col0" stroke="blue" stroke-width="0.5" text-anchor="middle">
			<rect height="9.0954" id="box_row0_col0" width="22.7294" x="24.0265" y="161.8959" />
			<text adjust="spacing" font-size="8.1859" id="text_row0_col0" length="18.1835" stroke="red" text-anchor="middle" x="35.3912" y="169.1722">Sun</text>
		</g>
		<g fill="none" id="row0_col1" stroke="blue" stroke-width="0.5" text-anchor="middle">
			<rect height="9.0954" id="box_row0_col1" width="22.7294" x="49.5971" y="161.8959" />
			<text adjust="spacing" font-size="8.1859" id="text_row0_col1" length="18.1835" stroke="red" text-anchor="middle" x="60.9618" y="169.1722">Mon</text>

t/fake-bahai.xml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="297mm" version="1.1" viewBox="0 0 210 297" width="210mm" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
	<g id="calendar" label="Calendar">
		<text fill="blue" id="month" style="font-size: 18.1907692307692" x="22.2411764705882" y="154.44">FakeBaha</text>
		<text fill="blue" id="year" style="text-align: end; text-anchor: end; font-size: 18.1907692307692" x="201.6" y="154.44">172</text>
		<rect height="97.24" id="bounding_box" style="fill:none; stroke: blue; stroke-width: 0.5;" width="179.2" x="22.4" y="160.38" />
		<g fill="none" id="row0_col0" stroke="blue" stroke-width="0.5" text-anchor="middle">
			<rect height="9.09538461538462" id="box_row0_col0" width="22.7294117647059" x="24.0264705882353" y="161.895897435897" />
			<text adjust="spacing" font-size="8.18584615384615" id="text_row0_col0" length="18.1835294117647" stroke="red" text-anchor="middle" x="35.3911764705882" y="169.172205128205">Sun</text>
		</g>
		<g fill="none" id="row0_col1" stroke="blue" stroke-width="0.5" text-anchor="middle">
			<rect height="9.09538461538462" id="box_row0_col1" width="22.7294117647059" x="49.5970588235294" y="161.895897435897" />
			<text adjust="spacing" font-size="8.18584615384615" id="text_row0_col1" length="18.1835294117647" stroke="red" text-anchor="middle" x="60.9617647058823" y="169.172205128205">Mon</text>



( run in 0.518 second using v1.01-cache-2.11-cpan-c333fce770f )