File Coverage

blib/lib/Date/Ethiopic.pm
Criterion Covered Total %
statement 17 48 35.4
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 22 53 41.5


line stmt bran cond sub pod time code
1             package Date::Ethiopic;
2 1     1   935 use base (Date::ICal);
  1         3  
  1         1178  
3              
4 1     1   15991 use utf8;
  1         11  
  1         6  
5             BEGIN
6             {
7 1     1   34 require 5.000;
8              
9 1     1   63 use strict;
  1         3  
  1         72  
10 1         2925 use vars qw(
11             $VERSION
12             $EPOCH
13              
14             @Tabots
15             @PagumeTabots
16             @PagumeTabotsTranscribed
17              
18             @YearNames
19              
20             @KokebDayNames
21             @KokebDayNamesTranscribed
22             @KokebMonthNames
23             @KokebMonthNamesTranscribed
24             @KokebYearNames
25             @KokebYearNamesTranscribed
26              
27             @EthiopicSeasonNames
28             @EthiopicSeasonNamesTranscribed
29              
30             @VariableTsomes
31             @VariableTsomesTranscribed
32             %VariableTsomes
33             %MiscellaneousTsomes
34             %MiscellaneousTsomesTranscribed
35             %MiscellaneousTsomes2
36             %MiscellaneousTsomes2Transcribed
37             %AnnualTsomes
38             %AnnualTsomesTranscribed
39             %LikaneTsomes
40             %LikaneTsomesTranscribed
41             %HawaryaTsomes
42             %HawaryaTsomesTranscribed
43             %StMaryTsomes
44             %StMaryTsomesTranscribed
45             %AksumTsomes
46             %AksumTsomesTranscribed
47              
48             $true
49             $false
50              
51             @GregorianDaysPerMonth
52              
53             $n
54 1     1   5 );
  1         2  
55              
56 1         3 $VERSION = "0.13";
57              
58 1         2 $EPOCH = 2796;
59              
60 1         2 ($false,$true) = (0,1);
61              
62 1         731 require Convert::Number::Ethiopic;
63 0           $n = new Convert::Number::Ethiopic;
64              
65 0           @GregorianDaysPerMonth = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
66              
67 0           @Tabots =(
68             [ "ልደታ", "Lideta" ],
69             [ "ታዴዎስና፡አባጉባ", "Tadiosna Abaguba" ],
70             [ "በአታ", "Beata" ],
71             [ "ዮሐንስ፡ሐዋርያው፡ወልደነጎድጓድ", "Yohannes : Hawariyaw : Weldenegodgwad" ],
72             [ "አቦ (አቡነ ገብረ ቅዱስ)", "Abo (Abune Gebre Kidus)" ],
73             [ "ኢያሱስ", "Yesus" ],
74             [ "ሥላሴ", "Selassie" ],
75             [ "አባ፡ኪሮስ", "Aba Kiros" ],
76             [ "ጨርቆስ", "Cherkos" ],
77             [ "መስቀል፡ኢየሱስ", "Meskel Yesus" ],
78             [ "ሐና፡ማርያም", "Hanna Mariam" ],
79             [ "ሚካኤል", "Michael" ],
80             [ "እግዚሐርአብ", "Egzihar Ab" ],
81             [ "አቡነ፡አረጋዊ", "Abune Aregawi" ],
82             [ "ጨርቆስ", "Cherkos" ],
83             [ "ኪዳነ፡ምሕረት", "Kidane Mihret" ],
84             [ "እስጢፋኖስ", "Estifanos" ],
85             [ "ቶማስ", "Tomas" ],
86             [ "ገብርኤል", "Gabriel" ],
87             [ "ሕንፅተ፡ቤተ፡ለማርያም", "Hinste Bete Lemariam" ],
88             [ "ማርያም", "Mariam" ],
89             [ "ኡራኤል", "Urael" ],
90             [ "ጊዮርጊስ", "Giorgis" ],
91             [ "ተክለ፡ሐይማኖት", "Tekle Haimanot" ],
92             [ "መርቆሪዎስ", "Merkoriwos" ],
93             [ "ዮሴፍ", "Yosef" ],
94             [ "መድኀኔ ዓለም", "Medehani Alem" ],
95             [ "አማኑኤል", "Amanuel" ],
96             [ "ባለ፡እግዚአብሔር", "Bale Egziabher" ],
97             [ "ዮሐንስ፡እና፡ማርቆስ", "Yohannes Ina Markos" ]
98             );
99 0           @PagumeTabots =(
100             "አሮጊቷ፡ልደታ",
101             "አሮጌ፡ታዴዎስና፡አባጉባ", # usual name
102             "ሩፋኤል",
103             "አሮጌ፡ዮሐንስ፡ሐዋርያው፡ወልደነጎድጓድ", # usual name
104             "አሮጌ፡አቦ (አቡነ፡ገብረ፡ቅዱስ)", # usual name
105             "አሮጌ፡ኢያሱስ" # usual name
106             );
107 0           @PagumeTabotsTranscribed =(
108             );
109 0           @VariableTsomes =(
110             "ነነዌ",
111             "በአታ ጾመ (ሁዳዴ የሚገባበት)",
112             "ደብረ ዘይት",
113             "ሆሣዕና",
114             "ስቅለት",
115             "ትንሣኤ",
116             "ረክበ ካህናት",
117             "ዕርገት",
118             "ጰራቅሊጦስ (ጰንጠቆስጤ)",
119             "ጾመ ሐዋርያት (የሰኔ ጾም)",
120             "ጾመ ድኅነት"
121             );
122 0           @VariableTsomesTranscribed =(
123             );
124 0           %VariableTsomes =(
125             "ነነዌ" => 0,
126             "በአታ ጾመ (ሁዳዴ የሚገባበት)" => 14,
127             "ደብረ ዘይት" => 41,
128             "ሆሣዕና" => 62,
129             "ስቅለት" => 67,
130             "ትንሣኤ" => 69,
131             "ረክበ ካህናት" => 93,
132             "ዕርገት" => 108,
133             "ጰራቅሊጦስ (ጰንጠቆስጤ)" => 118,
134             "ጾመ ሐዋርያት (የሰኔ ጾም)" => 119,
135             "ጾመ ድኅነት" => 121
136             );
137 0           %MiscellaneousTsomes =(
138             #
139             # ጾመ ገሀድ depends on the day ጥምቀት or ገና
140             # fall on (wed or fri), fix later.
141             #
142             "ጾመ ገሀድ" => [10,5],
143             "ማርያም" => [21,3]
144             );
145 0           %MiscellaneousTsomesTranscribed =(
146             );
147 0           %MiscellaneousTsomes2 =(
148             #
149             # we need a 2nd hash to avoid key clashes...
150             #
151             "ማርያም" => [21,9]
152             );
153 0           %MiscellaneousTsomes2Transcribed =(
154             );
155             #
156             # ዓመታዊ በዓል
157             #
158 0           %AnnualTsomes =(
159             "ርእስ ዓውደ ዓመት (እንቍጣጣሽ)" => [1,1],
160             "መስቀል (የመጣበት)" => [10,1],
161             "ደመራ" => [16,1],
162             "መስቀል (የተገኘበት)" => [17,1],
163             "ሚካአል" => [12,3],
164             "ጾመ ስብከት (የገና/የነቢያት ጾም)" => [15,3],
165             "ገብርኤል" => [19,4],
166             "ልደት" => [29,4],
167             "ግዝረት" => [6,5],
168             "ሥላሴ" => [7,5],
169             "ጥምቀት/ኤጲፋንያ" => [11,5],
170             "ቃና ዘገሊላ" => [12,5],
171             "ስምዖን" => [8,6],
172             "ገብርኤል" => [19,7],
173             "በዓለ መስቀል" => [10,7],
174             "መድኃኔ ዓለም" => [27,7],
175             "ትስብእት/በዓለ ወልድ" => [29,7],
176             "ጊዮርጊስ" => [23,8],
177             "ደብረ ታቦር (ቡሄ)" => [13,12]
178             );
179 0           %AnnualTsomesTranscribed =(
180             );
181             #
182             # የሊቃነ መላእክ ዕለት
183             #
184 0           %LikaneTsomes =(
185             "ራጉኤል" => [1,1],
186             "አፍኒን" => [8,3],
187             "ሚካኤል" => [12,3],
188             "ፋኑኤል" => [3,4],
189             "ሱርያል" => [27,5],
190             "ሳቁኤል" => [5,11],
191             "ኡራኤል" => [21,11],
192             "ሩፋኤል" => [3,13],
193             "አርባዕቱ እንስሳ" => [8,3],
194             "24ቱ ካህናተ ሰማይ" => [3,12],
195             );
196 0           %LikaneTsomesTranscribed =(
197             );
198             #
199             # የሐዋርያ/ወንጌላዊ በዓል
200             #
201 0           %HawaryaTsomes =(
202             "በርተሎሜዎስ" => [1,1],
203             "ማቴዎስ" => [12,2],
204             "እስጢፋኖስ" => [17,2],
205             "ሉቃስ" => [22,2],
206             "ፊሊጶስ" => [18,3],
207             "እንድርያስ" => [4,4],
208             "ዮሐንስ" => [4,5],
209             "ያዕቆብ ወልደ እልፍዮስ" => [10,6],
210             "ማትያስ" => [8,7],
211             "ያዕቆብ ወልደ ዘብዴዎስ" => [17,8],
212             "ማርቆስ" => [30,8],
213             "ቶማስ" => [26,9],
214             "ታዴዎስ" => [2,11],
215             "ጴጥሮስ ወጳውሎስ (የጾም ሐዋርያት ጾም መፍቻ)" => [5,11],
216             "ናትናኤል" => [10,11],
217             "ያዕቆብ የጌታ ወንድም" => [18,11]
218             );
219 0           %HawaryaTsomesTranscribed =(
220             );
221             #
222             # የቅድስት ማርያም በዓል =(
223             #
224 0           %StMaryTsomes =(
225             "ጼዴንያ" => [10,1],
226             "ደብረ ቍስቋም" => [6,3],
227             "በአታ" => [3,4],
228             "ድቅስዮስ" => [22,4],
229             "ገና" => [28,4],
230             "ልደት (ክርስቶስ የወለደችበት ዕለት)" => [29,4],
231             "ዕረፍት" => [21,5],
232             "ኪዳነ ምሕረት" => [16,6],
233             "ፅንሰት" => [29,7],
234             "ልደታ" => [1,9],
235             # genbot 24, 25?
236             # sene 8, 20 ?
237             "ጾም ፍልሰታ (የመቤታችን ጾም)" => [1,12], # check with ethiopica
238             "ቍጽረታ" => [7,12],
239             "ፍልሰታ (ኪዳነ ምሕረት) - የጾም መፍቻ" => [16,12], # check with book
240             "ሩፋኤል" => [3,13] # check with seattle group
241             );
242 0           %StMaryTsomesTranscribed =(
243             );
244 0           %AksumTsomes =(
245             "ጰንጠሌዎን" => [6,2],
246             "አረጋዊ/ዘሚካኤል" => [14,2],
247             "ይምአታ" => [28,2],
248             "ሊቃኖስ" => [25,3],
249             "ዖፅ" => [4,4],
250             "ሊባኖስ/መጣዕ" => [3,5],
251             "ጽሕማ" => [16,5],
252             "አሌፍ" => [11,7],
253             "አፍጼ" => [29,9],
254             "ጉባ" => [29,9],
255             "ይሥሐቅ/ገሪማ" => [17,10]
256             );
257 0           %AksumTsomesTranscribed =(
258             );
259 0           @YearNames =(
260             [ "ማቴዎስ", "Mateos" ],
261             [ "ማርቆስ", "Markos" ],
262             [ "ሉቃስ", "Lukas" ],
263             [ "ዮሐንስ", "Yohannes" ] # Leap Year
264             );
265 0           @KokebYearNames =(
266             "ምልክኤል",
267             "ሕልመልሜሌክ",
268             "ምልኤል",
269             "ናርኤል"
270             );
271 0           @KokebYearNamesTranscribed =(
272             );
273 0           @KokebDayNames =(
274             "አጣርድ",
275             "ዙሕራ",
276             "መሪሕ",
277             "መሽተሪ",
278             "ዙሐል",
279             "ኡራኑስ",
280             "ነይጡን"
281             );
282 0           @KokebDayNamesTranscribed =(
283             );
284 0           @KokebMonthNames =(
285             "ሚዛን",
286             "አቅራብ",
287             "ቀውስ",
288             "ጀደይ", # ጀዲ
289             "ደለው", # ደለዌ
290             "ሑት",
291             "ሐመል",
292             "ሠውር",
293             "ጀውዛ", # ገውዝ
294             "ሸርጣን",
295             "አሰድ",
296             "ሰንቡላ",
297             "ሰንቡላ" # Don't really know for ጳጉሜን
298             );
299 0           @KokebMonthNamesTranscribed =(
300             );
301 0           @EthiopicSeasonNames =(
302             "መጸው", # ከመስከረም ፳፭ እስከ ታኅሣሥ ፳፭
303             "ሐጋይ", # ክታኅሣሥ ፳፭ እስከ መጋቢት ፳፭
304             "ጸደይ", # ከመጋቢት ፳፭ እስከ ሰኔ ፳፭
305             "ክረምት" # ከሰኔ ፳፭ እስከ መስከረም ፳፭ # check this, its seems a
306             # a bit long for ክረምት
307             );
308 0           @EthiopicSeasonNamesTranscribed =(
309             );
310              
311             #
312             # Look into these later and how to calculate the days
313             #
314             #
315             # Islamic Holidays in Ethiopia
316             #
317             # የነቢዩ መሐመድ ልደት (መውሊድ) Birthday of Prophet Mohammed (Maulid)
318             # ኢድ አል ፈጥር (ረመዳን) Id Al Fetir (Remedan)
319             # ኢድ አል አድሐ (አረፋ) Id Al Adaha (Arefa)
320             #
321             # Islamic Holidays in Eritrea
322             #
323             # ልደተ ነቢዩ መሓመድ (መውሊድ) Birthday of Prophet Mohammed (Maulid)
324             # ዒድ ኣል ፈጥር (ረመዳን) Id Al-Fetir (Remedan)
325             # ዒድ ኣል ኣድሓ (ዓሪፋ) Id Al Adaha (Arefa)
326              
327             # ታቦት = \&tabot;
328             # ዘመነ = \&zemene;
329             # ጾመ = \&tsom;
330             }
331              
332              
333             sub new
334             {
335             my $class = shift;
336             my %args = @_ if ($#_);
337             my $self;
338              
339              
340             if ( ref($_[0]) && $_[0]->isa ("Date::ICal") ) {
341             #
342             # We assume a Gregorian calscale, though we should check it.
343             # Proposal a universal toGregorian or gregorian method to group.
344             #
345             my $ical = $_[0];
346             my $et = {}; bless $et, $class;
347             ( $args{day}, $args{month}, $args{year} )
348             = $et->fromGregorian ( $ical->day, $ical->month, $ical->year );
349             $self = $class->SUPER::new ( %args );
350             }
351             elsif ( $args{calscale} ) {
352             #
353             # A calender system has been specified:
354             #
355             if ( $args{calscale} =~ /gregorian/i ) {
356             #
357             # We have been given dates in the Gregorian system
358             # so we must convert into Ethiopic
359             #
360             my $et = {}; bless $et, $class;
361             if ( $args{ical} || $args{epoch} ) {
362             my $temp = $class->SUPER::new ( %args );
363             ( $args{day}, $args{month}, $args{year} )
364             = $et->fromGregorian ( $temp->day, $temp->month, $temp->year );
365             delete ( @args{'ical', 'epoch'} );
366             }
367             elsif ( $args{day} && $args{month} && $args{year} ) {
368             ( $args{day}, $args{month}, $args{year} )
369             = $et->fromGregorian ( $args{day}, $args{month}, $args{year} );
370             }
371             else {
372             die ( "Useless Gregorian context, no date args passed.\n" );
373             }
374             $self = $class->SUPER::new ( %args );
375             }
376             elsif ( $args{calscale} =~ /ethio/i ) {
377             $self = $class->SUPER::new ( %args );
378             $self->_isBogusEthiopicDate;
379             }
380             else {
381             die ( "Aborting: unknown calscale '$args{calscale}'\n" );
382             }
383             }
384             else {
385             #
386             # The Ethiopic calender system is assumed when unspecified:
387             #
388             $self = $class->SUPER::new ( %args );
389             $self->_isBogusEthiopicDate;
390             }
391              
392             $self->{_trans} = $false;
393             $self->{_is_tsome} = $false;
394              
395             bless $self, $class;
396             }
397              
398              
399             #
400             #
401             # Calender System Conversion Methods Below Here:
402             #
403             #
404             sub _AbsoluteToEthiopic
405             {
406             my ( $self, $absolute ) = @_;
407              
408             my $year = quotient ( 4 * ( $absolute - $EPOCH ) + 1463, 1461 );
409             my $month = 1 + quotient ( $absolute - $self->_EthiopicToAbsolute ( 1, 1, $year ), 30 );
410             my $day = ( $absolute - $self->_EthiopicToAbsolute ( 1, $month, $year ) + 1 );
411              
412             ( $day, $month, $year );
413             }
414              
415              
416             sub fromGregorian
417             {
418             my $self = shift;
419              
420             die ( "Bogus Ethiopic Date!!" ) if ( $self->_isBogusGregorianDate ( @_ ) );
421              
422             $self->_AbsoluteToEthiopic ( $self->_GregorianToAbsolute ( @_ ) );
423             }
424              
425              
426             sub gregorian
427             {
428             my $self = shift;
429              
430             $self->_AbsoluteToGregorian ( $self->_EthiopicToAbsolute ( @_ ) );
431             }
432              
433              
434             sub _isBogusEthiopicDate
435             {
436             my $self = shift;
437              
438             my($day, $month, $year) = (@_) ? @_ : ($self->day, $self->month, $self->year);
439              
440             ( !( 1 <= $day && $day <= 30 )
441             || !( 1 <= $month && $month <= 13 )
442             || ( $month == 13 && $day > 6 )
443             || ( $month == 13 && $day == 6 && !$self->isLeapYear )
444             )
445             ?
446             $true : $false;
447              
448             }
449              
450              
451             sub _isBogusGregorianDate
452             {
453             my $self = shift;
454              
455             my($day, $month, $year) = (@_) ? @_ : ($self->day, $self->month, $self->year);
456              
457             ( !( 1 <= $month && $month <= 12 )
458             || !( 1 <= $day && $day <= $GregorianDaysPerMonth[$month-1] )
459             || ( $day == 29 && $month == 2 && !$self->_isGregorianLeapYear($year) )
460             )
461             ?
462             $true : $false;
463              
464             }
465              
466              
467             sub _EthiopicToAbsolute
468             {
469             my $self = shift;
470             my ( $date, $month, $year ) = ( @_ ) ? @_ : ($self->day,$self->month,$self->year);
471              
472             ( $EPOCH - 1 + 365 * ( $year - 1 ) + quotient ( $year, 4 ) + 30 * ( $month - 1 ) + $date );
473             }
474              
475              
476             sub _GregorianYear
477             {
478             my ( $a ) = @_;
479              
480             my $b = $a - 1;
481             my $c = quotient ( $b, 146097 );
482             my $d = mod ( $b, 146097 );
483             my $e = quotient ( $d, 36524 );
484             my $f = mod ( $d, 36524 );
485             my $g = quotient ( $f, 1461 );
486             my $h = mod ( $f, 1461 );
487             my $i = quotient ( $h, 365 );
488             my $j = ( 400 * $c ) + ( 100 * $e ) + ( 4 * $g ) + $i;
489              
490             ( ( $e == 4 ) || ( $i == 4 ) )
491             ? $j
492             : ( $j + 1 )
493             ;
494             }
495              
496              
497             sub _AbsoluteToGregorian
498             {
499             my ( $self, $absolute ) = @_;
500              
501             my $year = _GregorianYear ( $absolute );
502              
503             my $priorDays = ( $absolute - $self->_GregorianToAbsolute ( 1, 1, $year ) );
504              
505             my $correction
506             = ( $absolute < $self->_GregorianToAbsolute ( 1, 3, $year ) )
507             ? 0
508             : ( $self->_isGregorianLeapYear ( $year ) )
509             ? 1
510             : 2
511             ;
512              
513             my $month = quotient ( ( ( 12 * ( $priorDays + $correction ) + 373 ) / 367 ), 1 );
514             my $day = $absolute - $self->_GregorianToAbsolute ( 1, $month, $year ) + 1;
515              
516             ( $day, $month, $year );
517             }
518              
519              
520             sub _GregorianToAbsolute
521             {
522             my $self = shift;
523             my ( $date, $month, $year ) = ( @_ ) ? @_ : ($self->day,$self->month,$self->year);
524              
525             my $correction
526             = ( $month <= 2 )
527             ? 0
528             : ( $self->_isGregorianLeapYear ( $year ) )
529             ? -1
530             : -2
531             ;
532              
533             my $absolute =(
534             365 * ( $year - 1 )
535             + quotient ( $year - 1, 4 )
536             - quotient ( $year - 1, 100 )
537             + quotient ( $year - 1, 400 )
538             + ( 367 * $month - 362 ) / 12
539             + $correction + $date
540             );
541              
542             quotient ( $absolute, 1 );
543             }
544              
545              
546             sub _isGregorianLeapYear
547             {
548             shift;
549              
550             (
551             ( ( $_[0] % 4 ) != 0 )
552             || ( ( $_[0] % 400 ) == 100 )
553             || ( ( $_[0] % 400 ) == 200 )
554             || ( ( $_[0] % 400 ) == 300 )
555             )
556             ? 0
557             : 1
558             ;
559             }
560              
561              
562             #
563             # argument is an ethiopic year
564             #
565             sub isLeapYear
566             {
567             my $self = shift;
568             my ( $year ) = ( @_ ) ? shift : $self->year;
569              
570             ( ( $year + 1 ) % 4 ) ? 0 : 1 ;
571             }
572              
573              
574             sub quotient
575             {
576             $_ = $_[0] / $_[1];
577              
578             s/\.(.*)//;
579              
580             $_;
581             }
582              
583              
584             sub mod
585             {
586             ( $_[0] - $_[1] * quotient ( $_[0], $_[1] ) );
587             }
588              
589              
590             #
591             # calscale and toGregorian and are methods I recommend every non-Gregorian
592             # based ICal package provide to identify itself and to convert the
593             # calendar system it handles into a normalized form.
594             #
595             sub calscale
596             {
597             "ethiopic";
598             }
599              
600              
601             sub toGregorian
602             {
603             my $self = shift;
604              
605             my ($day,$month,$year) = $self->gregorian;
606              
607             new Date::ICal ( day => $day, month => $month, year => $year );
608             }
609              
610              
611             sub format
612             {
613             my $self = shift;
614              
615             print "Ethiopic extended formatting is not yet implemented\n";
616             print "See: http://libeth.sourceforge.net/0.40/Dates.html\n";
617             return;
618              
619             $_ = shift;
620              
621             #
622             # see what's on libeth webpage
623             #
624             # http://libeth.sourceforge.net/0.40/Dates.html
625             #
626              
627             s/%M//; # replace with locale equivalent
628             s/%H//;
629             s/%Y//;
630             s/%EY//;
631             s/%m//;
632             s/%s//;
633             s/%EC//;
634             s/%Ey//;
635             s/%EY//;
636             s/%Od//;
637             s/%Oe//;
638             s/%OH//;
639             s/%OI//;
640             s/%Om//;
641             s/%Ou//;
642             s/%OU//;
643             s/%OV//;
644             s/%Ow//;
645             s/%OW//;
646             s/%Oy//;
647              
648             s/%-q//;
649             s/%-ta//;
650             s/%-ts//;
651             s/%-tsm//;
652             s/%-EN//;
653             s/%-ms//;
654             s/%-ys//;
655             s/%-sdm//;
656             s/%-sds//;
657              
658             }
659              
660              
661             sub full_date
662             {
663             my ($self) = shift;
664              
665             (@_)
666             ?
667             $self->day_name.$self->_sep.$self->month_name." ".$n->convert($self->day).$self->_daysep.$n->convert($self->year)." ".$self->ad
668             :
669             ( $self->{_trans} )
670             ?
671             $self->day_name(@_).$self->_sep.$self->month_name(@_)." ".$self->day.$self->_daysep.$self->year." ".$self->ad(@_)
672             :
673             $self->day_name.$self->_sep.$self->month_name." ".$self->day.$self->_daysep.$n->convert($self->year)." ".$self->ad
674             ;
675             }
676             sub long_date
677             {
678             my ($self) = shift;
679              
680             (@_)
681             ?
682             $n->convert($self->day)."-".$self->month_name."-".$n->convert($self->year)
683             :
684             ( $self->{_trans} )
685             ?
686             $self->day."-".$self->month_name(@_)."-".$self->year
687             :
688             $self->day."-".$self->month_name."-".$n->convert($self->year)
689             ;
690             }
691             sub medium_date
692             {
693             my ($self) = @_;
694            
695             my $year = $self->year;
696             $year =~ s/^\d\d//;
697              
698             ($#_)
699             ?
700             $self->day."-".$self->month_name."-".$n->convert($year)
701             :
702             ( $self->{_trans} )
703             ?
704             $self->day."-".$self->month_name(@_)."-".$year
705             :
706             $n->convert($self->day)."-".$self->month_name."-".$n->convert($year)
707             ;
708             }
709             sub short_date
710             {
711             $self->day."/".$self->month."/".$self->year
712             }
713             sub full_time
714             {
715             }
716             sub medium_time
717             {
718             }
719             sub short_time
720             {
721             }
722             sub date_time
723             {
724             }
725              
726              
727             sub day_name
728             {
729             my ( $self, $day ) = @_;
730              
731             $day ||= $self->_EthiopicToAbsolute;
732              
733             $day %= 7;
734              
735             my $pkg = ref($self);
736              
737             ${"${pkg}::Days"}[$day][$self->{_trans}];
738             }
739              
740              
741             sub short_day_name
742             {
743             my ( $self, $day ) = @_;
744              
745             $day ||= $self->_EthiopicToAbsolute;
746              
747             $day %= 7;
748              
749             my $pkg = ref($self);
750              
751             ${"${pkg}::ShortDays"}[$day][$self->{_trans}];
752             }
753              
754              
755             sub month_name
756             {
757             my ( $self, $month ) = @_;
758              
759             $month ||= $self->month;
760              
761             $month -= 1;
762              
763             my $pkg = ref($self);
764              
765             ${"${pkg}::Months"}[$month][$self->{_trans}];
766             }
767              
768              
769             sub short_month_name
770             {
771             my ( $self, $month ) = @_;
772              
773             $month ||= $self->month;
774              
775             $month -= 1;
776              
777             my $pkg = ref($self);
778              
779             ${"${pkg}::ShortMonths"}[$month][$self->{_trans}];
780             }
781              
782             #
783             #
784             # Methods for Language Independent Date Properites:
785             #
786             #
787              
788              
789             sub isTsomes
790             {
791             $_[0]->{_is_tsome};
792             }
793              
794              
795             sub tsomes
796             {
797             my $self = shift;
798             my ( $year ) = ( @_ ) ? shift : $self->year;
799              
800             my @Tsomes;
801             $#Tsomes = 50;
802             my $i = 0;
803              
804             my $pkg = ref($self);
805              
806             # Fixed Tsomes First
807             #
808             # Yuck... Lets simplify this later and get the tsomes sorted.
809             #
810             foreach my $key (keys %MiscellaneousTsomes) {
811             my $dm = $MiscellaneousTsomes{$key};
812             my $tsome = $pkg->new ( day => $dm->[0], month => $dm->[1], year => $year );
813             $tsome->{_tsome_name} = $key;
814             $tsome->{_tsome_category} = "misc"; # fix later
815             $tsome->{_is_tsome} = $true;
816             $Tsomes[$i++] = $tsome;
817             }
818             foreach my $key (keys %MiscellaneousTsomes2) {
819             my $dm = $MiscellaneousTsomes2{$key};
820             my $tsome = $pkg->new ( day => $dm->[0], month => $dm->[1], year => $year );
821             $tsome->{_tsome_name} = $key;
822             $tsome->{_tsome_category} = "misc"; # fix later
823             $tsome->{_is_tsome} = $true;
824             $Tsomes[$i++] = $tsome;
825             }
826             foreach my $key (keys %AnnualTsomes) {
827             my $dm = $AnnualTsomes{$key};
828             my $tsome = $pkg->new ( day => $dm->[0], month => $dm->[1], year => $year );
829             $tsome->{_tsome_name} = $key;
830             $tsome->{_tsome_category} = "ዓመታዊ በዓል";
831             $tsome->{_is_tsome} = $true;
832             $Tsomes[$i++] = $tsome;
833             }
834             foreach my $key (keys %LikaneTsomes) {
835             my $dm = $LikaneTsomes{$key};
836             my $tsome = $pkg->new ( day => $dm->[0], month => $dm->[1], year => $year );
837             $tsome->{_tsome_name} = $key;
838             $tsome->{_tsome_category} = "የሊቃነ መላእክ ዕለት";
839             $tsome->{_is_tsome} = $true;
840             $Tsomes[$i++] = $tsome;
841             }
842             foreach my $key (keys %HawaryaTsomes) {
843             my $dm = $HawaryaTsomes{$key};
844             my $tsome = $pkg->new ( day => $dm->[0], month => $dm->[1], year => $year );
845             $tsome->{_tsome_name} = $key;
846             $tsome->{_tsome_category} = "የሐዋርያ/ወንጌላዊ በዓል";
847             $tsome->{_is_tsome} = $true;
848             $Tsomes[$i++] = $tsome;
849             }
850             foreach my $key (keys %StMaryTsomes) {
851             my $dm = $StMaryTsomes{$key};
852             my $tsome = $pkg->new ( day => $dm->[0], month => $dm->[1], year => $year );
853             $tsome->{_tsome_name} = $key;
854             $tsome->{_tsome_category} = "የቅድስት ማርያም በዓል";
855             $tsome->{_is_tsome} = $true;
856             $Tsomes[$i++] = $tsome;
857             }
858             foreach my $key (keys %AksumTsomes) {
859             my $dm = $AksumeTsomes{$key};
860             my $tsome = $pkg->new ( day => $dm->[0], month => $dm->[1], year => $year );
861             $tsome->{_tsome_name} = $key;
862             $tsome->{_tsome_category} = "የአክሱም ዘመነ";
863             $tsome->{_is_tsome} = $true;
864             $Tsomes[$i++] = $tsome;
865             }
866              
867             #
868             # Computer Variable Tsomes
869             #
870             my $aa = 5500 + $year; # ዓመተ ዓለም
871             my $w = ($aa - 1) % 19; # ወምበር
872             my $ab = ($w * 11) % 30; # አበቅቴ
873             my $m = 30 - $ab; # መጥቅዕ
874              
875             my $wr = ($m < 15) ? 2 : 1; # ወር
876              
877             my $ly = int (($aa - 1) / 4); # leap year
878              
879             my $p = ($year % 4) ? 0 : 1 ;
880              
881             my $td = ($aa - 1) * 365 + $ly + $p;
882             my $s = (($td + 1) % 7) + 1;
883             my $tdm = $td + ($wr - 1) * 30 + $m;
884             my $d = (($tdm % 7) + 1);
885             my $f = 129 - ((($d + 1) % 7) + 1);
886              
887             foreach my $key (@VariableTsomes) {
888             my $tdbi = $tdm + $f + $VariableTsomes{$key};
889             my $wri = int(($tdbi - $td) / 30);
890             my $di = (($tdbi - $td) % 30);
891             $di ||= 30;
892             $wri = $wri + 1 if ($di > 0);
893              
894             my $is = (($tdbi % 7) + 1);
895            
896             my $tsome = $pkg->new ( day => $di, month => $wri, year => $year );
897             $tsome->{_tsome_name} = $key;
898             $Tsomes[$i++] = $tsome;
899             }
900              
901             @Tsomes;
902             }
903              
904              
905             sub dayStar
906             {
907             my $self = shift;
908             my ( $day ) = ( @_ ) ? shift : $self->day;
909              
910             ( $self->{_trans} ) ? $KokebDayNamesTranscribed[$day%7] : $KokebDayNames[$day%7] ;
911              
912             }
913              
914              
915             sub monthStar
916             {
917             my $self = shift;
918             my ( $month ) = ( @_ ) ? shift : $self->month;
919              
920             ( $self->{_trans} ) ? $KokebMonthNamesTranscribed[$month%13] : $KokebMonthNames[$month%13] ;
921             }
922              
923              
924             sub yearStar
925             {
926             my $self = shift;
927             my ( $year ) = ( @_ ) ? shift : $self->year;
928              
929             ( $self->{_trans} ) ? $KokebYearNamesTranscribed[$year%4] : $KokebYearNames[$year%4] ;
930             }
931              
932              
933             sub season
934             {
935             my $self = shift;
936              
937             my ($day,$month) = ($self->day,$self->month);
938             my $season;
939             my $daysThusFar = ($month-1)*30 + $day;
940              
941             ( $daysThusFar < 25 )
942             ? "ክረምት"
943             : ( $daysThusFar < (3*30+24) )
944             ? "መጸው"
945             : ( $daysThusFar < (6*30+24) )
946             ? "ሐጋይ"
947             : ( $daysThusFar < (9*30+24) )
948             ? "ጸደይ"
949             : "ክረምት"
950             ;
951              
952             }
953              
954              
955             sub tabot
956             {
957             my $self = shift;
958              
959             my ($day,$month) = ($self->day,$self->month);
960              
961             ( $month == 13 )
962             ? ( $self->{_trans} )
963             ? $PagumeTabotsTranscribed[$day]
964             : $PagumeTabots[$day]
965             : $Tabots[$day][$self->{_trans}]
966             ;
967             }
968              
969              
970             sub zemene
971             {
972             my $self = shift;
973             my ( $year ) = ( @_ ) ? shift : $self->year;
974              
975             $YearNames[($year%4)][$self->{_trans}];
976             }
977              
978              
979             sub yearName { zemene(@_); }
980              
981              
982             sub useTranscription
983             {
984             my $self = shift;
985              
986             $self->{_trans} = shift if (@_);
987              
988             $self->{_trans};
989             }
990              
991              
992             #########################################################
993             # Do not change this, Do not put anything below this.
994             # File must return "true" value at termination
995             1;
996             ##########################################################
997              
998             __END__