Calendar-Saka

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

      - Updated pod document with regard to the Calendar::Plugin::Renderer v0.06.

1.24  Mon Jan 11 09:45:00 2016
      - Added method as_svg() using the plugin Calendar::Plugin::Renderer.

1.23  Sat Aug 29 14:55:00 2015
      - Upgraded to use Date::Saka::Simple v0.09.

1.22  Tue Aug 11 11:45:00 2015
      - Upgraded to use Date::Saka::Simple v0.08.
      - Making use of the method get_calendar() provided by Date::Saka::Simple.

1.21  Fri Jul 10 10:05:00 2015
      - Upgraded to use Date::Saka::Simple v0.07.

1.20  Tue Jun 30 11:00:00 2015
      - Upgraded the dependency on Date::Saka::Simple v0.06.
      - Removed the dependecy on Date::Utils, no longer required.

1.19  Sat Jun 20 19:40:00 2015
      - Fixed the bug in the method from_gregorian().

1.18  Fri Jun 12 10:00:00 2015
      - Updated method _calendar() to validate month and year.

1.17  Mon May 25 14:40:00 2015
      - Dropped the dependency on Date::Utils::Saka.
      - Upgraded the dependency on Date::Saka::Simple v0.05.
      - Updated code w.r.t the above changes.

1.16  Sat May 02 20:50:00 2015
      - Added LICENSE file.

1.15  Thu Apr 23 23:45:00 2015
      - Re-structured and consumed Date::Utils::Saka as Moo Role.

1.14  Tue Apr 21 13:50:10 2015
      - Fixed the bug in the method _calendar() the last cell is empty.

1.13  Tue Apr 21 10:20:10 2015
      - Complete re-write using Moo with unit tests.

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

1.11  Fri Sep 12 22:30:19 2014

Changes  view on Meta::CPAN

0.06  Mon Apr 18 16:54:00 2011
      - Renamed title "Month Names" to "MONTHS" and set it head1.
      - Removed title "Saka Calendar for the month of Phalgun year 1932.".
      - Cosmetics changes.

0.05  Tue Apr 12 12:05:00 2011
      - Fixed buggy internal method _validate_date().
      - Added unit test 05-test-case.t

0.04  Tue Mar 29 10:53:10 2011
      - Added more information about the month name and weekdays of Saka calendar.

0.03  Fri Mar 18 14:15:16 2011
      - Corrected typo in the SYNOPSIS.

0.02  Fri Mar 18 12:29:00 2011
      - Renamed month "Caitra" to "Chaitra".
      - Updated SYNOPSIS to tell more about Saka Calendar.
      - Renamed method _days_in_caitra() to _days_in_chaitra().
      - Updated method to_julian() and from_julian() for month name "Chaitra".
      - Cleaned up method as_string() and method get_calendar().
      - Updated test 04-test-case.t for month name "Chaitra".
      - Updated pod for method days_in_year_month().

0.01  Thu Mar 17 16:10:29 2011
      - First version released.

MANIFEST  view on Meta::CPAN

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

Module  to  play  with Saka calendar  mostly  used  in  the South indian, Goa and
Maharashatra. It supports the functionality to add / minus days, months and years
to a Saka date. It can also converts Saka date to Gregorian/Julian date.

The  Saka eras are lunisolar calendars, and feature annual cycles of twelve lunar
months, each month divided into two phases:   the  'bright half' (shukla) and the
'dark half'  (krishna);  these correspond  respectively  to  the  periods  of the
'waxing' and the 'waning' of the moon. Thus, the  period beginning from the first
day  after  the new moon  and  ending on the full moon day constitutes the shukla
paksha or 'bright half' of the month the period beginning from the  day after the
full moon until &  including the next new moon day constitutes the krishna paksha
or 'dark half' of the month.

The  "year zero"  corresponds  to  78 BCE in the Saka calendar. The Saka calendar
begins with the month of Chaitra (March) and the Ugadi/Gudi Padwa festivals  mark
the new year.

Each  month  in  the Shalivahana  calendar  begins with the  'bright half' and is
followed by the 'dark half'.  Thus,  each  month of the Shalivahana calendar ends
with the no-moon day and the new month begins on the day after that.

A variant of the Saka Calendar was reformed & standardized as the Indian National
calendar in 1957. This official  calendar follows the Shalivahan Shak calendar in
beginning from the month of Chaitra and counting years with 78 CE being year zero.
It features a constant number of days in every month with leap years.Saka Calendar
for the month of Chaitra year 1937

    +----------------------------------------------------------------------------------------------------------------------+
    |                                                 Chaitra    [1937 BE]                                                 |
    +----------------+----------------+----------------+----------------+----------------+----------------+----------------+
    |       Ravivara |        Somvara |    Mangalavara |      Budhavara | Brahaspativara |      Sukravara |       Sanivara |
    +----------------+----------------+----------------+----------------+----------------+----------------+----------------+
    |              1 |              2 |              3 |              4 |              5 |              6 |              7 |

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

    |              8 |              9 |             10 |             11 |             12 |             13 |             14 |
    +----------------+----------------+----------------+----------------+----------------+----------------+----------------+
    |             15 |             16 |             17 |             18 |             19 |             20 |             21 |
    +----------------+----------------+----------------+----------------+----------------+----------------+----------------+
    |             22 |             23 |             24 |             25 |             26 |             27 |             28 |
    +----------------+----------------+----------------+----------------+----------------+----------------+----------------+
    |             29 |             30 |                                                                                    |
    +----------------+----------------+----------------+----------------+----------------+----------------+----------------+

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

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

    # prints saka month calendar in which the given gregorian date falls in.
    print Calendar::Saka->new->from_gregorian(2015, 4, 19), "\n";

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

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

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

=head1 SAKA MONTHS

    +-------+-------------------------------------------------------------------+
    | Order | Name                                                              |
    +-------+-------------------------------------------------------------------+
    |   1   | Chaitra                                                           |
    |   2   | Vaisakha                                                          |
    |   3   | Jyaistha                                                          |

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

    |    3    | Wednesday | Budhavara                                           |
    |    4    | Thursday  | Brahaspativara                                      |
    |    5    | Friday    | Sukravara                                           |
    |    6    | Saturday  | Sanivara                                            |
    +---------+-----------+-----------------------------------------------------+

=head1 METHODS

=head2 current()

Returns current month of the Saka calendar.

=cut

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

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

=head2 from_gregorian()

Returns saka 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 saka month calendar in which the given julian date falls in.

=cut

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

    my $date = $self->from_julian($julian);
    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::Saka::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  Saka  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::Saka::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/Saka.pm  view on Meta::CPAN

=head1 AUTHOR

Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >>

=head1 REPOSITORY

L<https://github.com/manwar/Calendar-Saka>

=head1 BUGS

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

t/fake-saka.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">FakeChaitra</text>
		<text fill="blue" id="year" style="text-align: end; text-anchor: end; font-size: 18.1907692307692" x="201.6" y="154.44">1937</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.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>

t/saka.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">Chaitra</text>
		<text fill="blue" id="year" style="text-align: end; text-anchor: end; font-size: 18.1908" x="201.6000" y="154.4400">1937</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.529 second using v1.01-cache-2.11-cpan-c333fce770f )