Date-Bahai-Simple
view release on metacpan or search on metacpan
lib/Date/Bahai/Simple.pm view on Meta::CPAN
sub get_major_cycle_year {
my ($self, $bahai_year) = @_;
my $major = floor($bahai_year / 361) + 1;
my $cycle = floor(($bahai_year % 361) / 19) + 1;
my $year = ($bahai_year % 19) + 1;
return ($major, $cycle, $year);
}
sub validate_month {
my ($self, $month) = @_;
if (defined $month && ($month =~ /[A-Z]/i)) {
return $self->validate_month_name($month);
}
my @caller = caller(0);
@caller = caller(2) if ($caller[3] eq '(eval)');
Date::Exception::InvalidMonth->throw({
method => __PACKAGE__."::validate_month",
message => sprintf("ERROR: Invalid month [%s].", defined($month)?($month):('')),
filename => $caller[1],
line_number => $caller[2] })
unless (defined($month) && ($month =~ /^\d{1,2}$/) && ($month >= 1) && ($month <= 20));
}
sub validate_day {
my ($self, $day) = @_;
my @caller = caller(0);
@caller = caller(2) if $caller[3] eq '(eval)';
Date::Exception::InvalidDay->throw({
method => __PACKAGE__."::validate_day",
message => sprintf("ERROR: Invalid day [%s].", defined($day)?($day):('')),
filename => $caller[1],
line_number => $caller[2] })
unless (defined($day) && ($day =~ /^\d{1,2}$/) && ($day >= 1) && ($day <= 19));
}
sub as_string {
my ($self) = @_;
return sprintf("%d, %s %d BE",
$self->day, $self->get_month_name, $self->get_year);
}
#
#
# PRIVATE METHODS
sub _vernal_equinox_month_day {
my ($year) = @_;
# Source: Wikipedia
# In 2014, the Universal House of Justice selected Tehran, the birthplace of
# Baha'u'lláh, as the location to which the date of the vernal equinox is to
# be fixed, thereby "unlocking" the Badi calendar from the Gregorian calendar.
# For determining the dates, astronomical tables from reliable sources are
# used.
# In the same message the Universal House of Justice decided that the
# birthdays of the Bab and Baha'u'lláh will be celebrated on "the first and
# the second day following the occurrence of the eighth new moon after
# Naw-Ruz" (also with the use of astronomical tables) and fixed the dates of
# the Bahaà Holy Days in the Baha'à calendar, standardizing dates for Baha'Ãs
# worldwide. These changes came into effect as of sunset on 20 March 2015.The
# changes take effect from the next Bahai New Year, from sunset on March 20,
# 2015.
my $month = 3;
my $day = 20;
if ($year >= 2015) {
my $equinox_date = calculate_equinox('mar', 'utc', $year);
if ($equinox_date =~ /\d{4}\-(\d{2})\-(\d{2})\s/) {
$month = $1;
$day = $2;
}
}
return ($month, $day);
}
=head1 AUTHOR
Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >>
=head1 REPOSITORY
L<https://github.com/manwar/Date-Bahai-Simple>
=head1 SEE ALSO
=over 4
=item L<Date::Gregorian::Simple>
=item L<Date::Hebrew::Simple>
=item L<Date::Hijri::Simple>
=item L<Date::Julian::Simple>
=item L<Date::Persian::Simple>
=item L<Date::Saka::Simple>
=back
=head1 BUGS
Please report any bugs / feature requests to C<bug-date-bahai-simple at rt.cpan.org>,
or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Date-Bahai-Simple>.
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 Date::Bahai::Simple
You can also look for information at:
=over 4
( run in 2.352 seconds using v1.01-cache-2.11-cpan-fe3c2283af0 )