Calendar-Gregorian
view release on metacpan or search on metacpan
LICENSE
Changes
MANIFEST
MANIFEST.SKIP
Makefile.PL
README
lib/Calendar/Gregorian.pm
t/00-load.t
t/calendar-gregorian.t
t/fake-gregorian.xml
t/gregorian.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/Gregorian.pm view on Meta::CPAN
| 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::Gregorian;
# prints current gregorian month calendar.
print Calendar::Gregorian->new, "\n";
print Calendar::Gregorian->new->current, "\n";
# prints gregorian month calendar for the first month of year 2016.
print Calendar::Gregorian->new({ month => 1, year => 2016 }), "\n";
# prints gregorian month calendar in which the given julian date falls in.
print Calendar::Gregorian->new->from_julian(2457102.5), "\n";
# prints current month gregorian calendar in SVG format.
print Calendar::Gregorian->new->as_svg;
# prints current month gregorian calendar in text format.
print Calendar::Gregorian->new->as_text;
=head1 GREGORIAN MONTHS
+--------+------------------------------------------------------------------+
| Number | Name |
+--------+------------------------------------------------------------------+
| 1 | January |
| 2 | February |
| 3 | March |
lib/Calendar/Gregorian.pm view on Meta::CPAN
| Wednesday |
| Thursday |
| Friday |
| Saturday |
+---------------------------------------------------------------------------+
=head1 METHODS
=head2 current()
Returns current month of the Gregorian calendar.
=cut
sub current {
my ($self) = @_;
return $self->as_text($self->date->month, $self->date->year);
}
=head2 from_julian($julian_date)
Returns Gregorian month calendar in which the given julian date falls in.
=cut
sub from_julian {
my ($self, $julian) = @_;
my $date = $self->date->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::Gregorian::Simple->new({ year => $year, month => $month, day => 1 });
return $self->svg_calendar(
{
start_index => $date->day_of_week,
month_name => $date->months->[$month],
days => $date->days_in_month_year($month, $year),
year => $year
});
}
=head2 as_text($month, $year)
Returns color coded Gregorian 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::Gregorian::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/Gregorian.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-gregorian at rt.cpan.org>
or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Calendar-Gregorian>.
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::Gregorian
t/fake-gregorian.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">Max</text>
<text fill="blue" id="year" style="text-align: end; text-anchor: end; font-size: 18.1908" x="201.6000" y="154.4400">2000</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/gregorian.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">May</text>
<text fill="blue" id="year" style="text-align: end; text-anchor: end; font-size: 18.1908" x="201.6000" y="154.4400">2016</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 1.492 second using v1.01-cache-2.11-cpan-39bf76dae61 )