Calendar-Persian

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

      - Added method as_svg() using the plugin Calendar::Plugin::Renderer.
      - Upgraded to use Date::Persian::Simple v0.08.
      - Added section "SEE ALSO".
      - Updated copyright year information.

0.22  Mon Aug 31 12:20:00 2015
      - Upgraded to use Date::Persian::Simple v0.07.

0.21  Sun Jul 19 11:15:00 2015
      - Upgraded to use Date::Persian::Simple v0.06.
      - Making use of the method get_calendar() provided by Date::Persian::Simple.

0.20  Thu Jul 09 09:45:00 2015
      - Upgraded to use Date::Persian::Simple v0.05.

0.19  Mon Jun 29 03:25:00 2015
      - Upgraded the dependency on Date::Persian::Simple v0.04.

0.18  Fri Jun 19 10:15:00 2015
      - Fixed the bug in the method from_gregorian().

0.17  Thu Jun 11 10:45:00 2015
      - Updated method _calendar() to validate month and year.

0.16  Mon May 25 13:05:00 2015
      - Dropped the dependency on Date::Utils::Persian.
      - Upgraded the dependency on Date::Persian::Simple v0.03.
      - Updated code w.r.t the above changes.

0.15  Thu Apr 30 12:20:00 2015
      - Added LICENSE file.

0.14  Thu Apr 23 23:40:00 2015
      - Re-structured and consumed Date::Utils::Persian as Moo Role.

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

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

0.11  Sat Apr 18 03:40:00 2015
      - Complete re-write of the entire distribution using Moo with unit tests.

0.10  Fri Jan 16 15:10:10 2015
      - Removed SIGNATURE file.
      - Updated MANIFEST.SKIP file to ignore folder 'eumm/'.
      - Updated Copyright year information.

0.09  Fri Sep 12 19:42:17 2014

Changes  view on Meta::CPAN

      - Renamed the title "Persian Calendar for the month of Farvadin year 1390.".
      - Renamed the title "Month Names" to "MONTHS" and set it head1.
      - Set the title "WEEKDAYS" as head1.
      - Minor cosmetics changes.

0.05  Tue Apr 12 12:45:11 2011
      - Fixed the internal method _validate_date().
      - Added unit test 01-test-case.t

0.04  Fri Apr 08 18:58:00 2011
      - Fixed one more typo in the pod for method get_calendar().
      - Removed boilerplate test.

0.03  Fri Apr 08 16:17:18 2011
      - Updated pod for SYNOPSIS.
      - Fixed pod for method days_in_year_month().
      - Fixed pod for method get_calendar().

0.02  Tue Mar 29 10:35:10 2011
      - Added more information about the Persian calendar to the pod.

0.01  Thu Mar 28 17:11:23 2011
      - First version released.

MANIFEST  view on Meta::CPAN

Changes
MANIFEST
MANIFEST.SKIP
Makefile.PL
README
LICENSE
lib/Calendar/Persian.pm
t/00-load.t
t/calendar-persian.t
t/persian.xml
t/fake-persian.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)

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

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

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

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

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

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

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

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

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

=head1 PERSIAN MONTHS

    +-------+-------------------------------------------------------------------+
    | Month | Persian Name                                                      |
    +-------+-------------------------------------------------------------------+
    |     1 | Farvardin                                                         |
    |     2 | Ordibehesht                                                       |
    |     3 | Xordad                                                            |

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


=head1 CONSTRUCTOR

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

=head1 METHODS

=head2 current()

Returns current month of the Persian calendar.

=cut

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

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

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

Returns persian 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 persian 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. 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 = Date::Persian::Simple->new({ year => $year, month => $month, day => 1 });

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

=head2 as_text($month, $year)

Returns  color  coded  Persian  calendar for the given C<$month> and C<$year>. 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 = Date::Persian::Simple->new({ year => $year, month => $month, day => 1 });

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

sub as_string {

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

=item L<Calendar::Hijri>

=item L<Calendar::Gregorian>

=item L<Calendar::Saka>

=back

=head1 BUGS

Please report any bugs or feature requests to C<bug-calendar-persian at rt.cpan.org>,
or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Calendar-Persian>.
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::Persian

t/fake-persian.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">Ordibehesht</text>
		<text fill="blue" id="year" style="text-align: end; text-anchor: end; font-size: 18.1908" x="201.6000" y="154.4400">1300</text>
		<rect height="118.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/persian.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">Ordibehesht</text>
		<text fill="blue" id="year" style="text-align: end; text-anchor: end; font-size: 18.1908" x="201.6000" y="154.4400">1395</text>
		<rect height="118.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>



( run in 0.658 second using v1.01-cache-2.11-cpan-5dc5da66d9d )