Date-Ethiopic
view release on metacpan or search on metacpan
lib/Date/Ethiopic.pm view on Meta::CPAN
my $absolute =(
365 * ( $year - 1 )
+ quotient ( $year - 1, 4 )
- quotient ( $year - 1, 100 )
+ quotient ( $year - 1, 400 )
+ ( 367 * $month - 362 ) / 12
+ $correction + $date
);
quotient ( $absolute, 1 );
}
sub _isGregorianLeapYear
{
shift;
(
( ( $_[0] % 4 ) != 0 )
|| ( ( $_[0] % 400 ) == 100 )
|| ( ( $_[0] % 400 ) == 200 )
|| ( ( $_[0] % 400 ) == 300 )
)
? 0
: 1
;
}
#
# argument is an ethiopic year
#
sub isLeapYear
{
my $self = shift;
my ( $year ) = ( @_ ) ? shift : $self->year;
( ( $year + 1 ) % 4 ) ? 0 : 1 ;
}
sub quotient
{
$_ = $_[0] / $_[1];
s/\.(.*)//;
$_;
}
sub mod
{
( $_[0] - $_[1] * quotient ( $_[0], $_[1] ) );
}
#
# calscale and toGregorian and are methods I recommend every non-Gregorian
# based ICal package provide to identify itself and to convert the
# calendar system it handles into a normalized form.
#
sub calscale
{
"ethiopic";
}
sub toGregorian
{
my $self = shift;
my ($day,$month,$year) = $self->gregorian;
new Date::ICal ( day => $day, month => $month, year => $year );
}
sub format
{
my $self = shift;
print "Ethiopic extended formatting is not yet implemented\n";
print "See: http://libeth.sourceforge.net/0.40/Dates.html\n";
return;
$_ = shift;
#
# see what's on libeth webpage
#
# http://libeth.sourceforge.net/0.40/Dates.html
#
s/%M//; # replace with locale equivalent
s/%H//;
s/%Y//;
s/%EY//;
s/%m//;
s/%s//;
s/%EC//;
s/%Ey//;
s/%EY//;
s/%Od//;
s/%Oe//;
s/%OH//;
s/%OI//;
s/%Om//;
s/%Ou//;
s/%OU//;
s/%OV//;
s/%Ow//;
s/%OW//;
s/%Oy//;
s/%-q//;
s/%-ta//;
s/%-ts//;
s/%-tsm//;
s/%-EN//;
s/%-ms//;
lib/Date/Ethiopic.pm view on Meta::CPAN
my $self = shift;
my ( $year ) = ( @_ ) ? shift : $self->year;
$YearNames[($year%4)][$self->{_trans}];
}
sub yearName { zemene(@_); }
sub useTranscription
{
my $self = shift;
$self->{_trans} = shift if (@_);
$self->{_trans};
}
#########################################################
# Do not change this, Do not put anything below this.
# File must return "true" value at termination
1;
##########################################################
__END__
=head1 NAME
Date::Ethiopic - ICalendar for the Ethiopic Calendar System.
=head1 SYNOPSIS
use Date::Ethiopic;
#
# typical instantiation:
#
my $ethio = new Date::Ethiopic ( day => 29, month => 6, year => 1995 );
$ethio = new Date::Ethiopic ( ical => '19950629' ); # the same
#
# Get Gregorian Date:
#
my ($d,$m,$y) = $ethio->gregorian;
#
# instantiate with a Gregorian date, date will be converted.
#
$ethio = new Date::Ethiopic ( ical => '20030308', calscale => 'gregorian' );
#
# instantiate with a Date::ICal object, assumed to be in Gregorian
#
my $grego = new Date::ICal ( ical => '20030308' );
$ethio = new Date::Ethiopic ( $grego );
#
# get a Date::ICal object in the Gregorian calendar system
#
$grego = $ethio->toGregorian;
=head1 DESCRIPTION
The Date::Ethiopic module provides methods for accessing date information
in the Ethiopic calendar system. The module will also convert dates to
and from the Gregorian system.
=head2 Limitations
In the Gregorian system the rule for adding a 29th day to February during
leap year follows as per; February will have a 29th day:
(((((every 4 years) except every 100 years) except every 400 years) except every 2,000) except (maybe every 16,000 years))
The Ethiopic calendar gets an extra day at the end of the 13th month on leap
year (which occurs the year before Gregorian leap year).
It is not known however if the Ethiopic calendar follows the 2,000 year rule.
If it does NOT follow the 2,000 year rule the consequence would be that the
difference between the two calendar systems will increase by a single day.
Hence if you reckon your birthday in the Ethiopic system, that date in
Gregorian may change in five years. The algorithm here here assumes that
the Ethiopic system will follow the 2,000 year rule.
This may however become a moot point when we consider:
=head2 The Impending Calamity at the End of Time
Well, it is more of a major reset. Recent reports from reliable sources
indicate that every
1,000 years the Ethiopic calendar goes thru a major upheaval whereby
the calendar gets resyncronized with either September 1st or possibly
even October 1st. Accordingly Nehasse would then either end on the 25th
day or Pagumen would be extend to 25 days. Noone will know their birthday
any more, Christmas or any other date that ever once had meaning. Chaos
will indeed rule the world.
Unless everyone gets little calendar converting applets running on their wrist
watches, that would rule. But before you start coding applets for future
embeded systems, lets get this clarified. Consider that the Gregorian
calendar system is less than 500 years old, so this couldn't have happend
a 1,000 years ago, perhaps with the Julian calendar. Since the Ethiopic
calendar is still in sync with the Coptic, the Copts must have gone thru
the same upheaval.
We are following this story closely, stay tuned to these man pages
for updates as they come in.
=head1 CREDITS
=over 4
=item * Calendrical Calculations: L<http://www.calendarists.com/>
=item * Bahra Hasab: L<http://www.hmml.org/events/>
=item * LibEth: L<http://libeth.sourceforge.net/>
=item * Ethiopica: L<http://ethiopica.sourceforge.net/>
=item * Saint Gebriel Ethiopian Orthodox Church of Seattle: L<http://www.st-gebriel.org/>
=item * Aklile Birhan Wold Kirkos, Metsaheit Tibeb, Neged Publishers, Addis Ababa, 1955 (1948 EC).
=back
=head1 REQUIRES
Date::ICal and L<Convert::Number::Ethiopic>. It should work with
any version of Perl. L<Convert::Number::Ethiopic> is only required
if you want to display years and days in Ethiopic numerals.
=head1 LICENSE AND COPYRIGHT
Copyright (c) 2003-2025, Daniel Yacob C<< <dyacob@cpan.org> >>. All rights reserved.
The conversion algorithms are derived from the original work in Emacs
Lisp by Reingold, Dershowitz and Clamen which later grew into the
excellent reference Calendrical Calculations. The Emacs package carries
the following message:
;; The Following Lisp code is from ``Calendrical
;; Calculations'' by Nachum Dershowitz and Edward
;; M. Reingold, Software---Practice & Experience, vol. 20,
;; no. 9 (September, 1990), pp. 899--928 and from
;; ``Calendrical Calculations, II: Three Historical
;; Calendars'' by Edward M. Reingold, Nachum Dershowitz,
;; and Stewart M. Clamen, Software---Practice & Experience,
;; vol. 23, no. 4 (April, 1993), pp. 383--404.
;; This code is in the public domain, but any use of it
;; should publically acknowledge its source.
Otherwise, this module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
=head1 BUGS
None presently known.
=head1 AUTHOR
Daniel Yacob, L<dyacob@cpan.org|mailto:dyacob@cpan.org>
=head1 SEE ALSO
Ethiopica L<http://ethiopica.sourceforge.net>
=cut
( run in 1.261 second using v1.01-cache-2.11-cpan-6de40a662fe )