File Coverage

blib/lib/Date/Ethiopic.pm
Criterion Covered Total %
statement 114 303 37.6
branch 22 92 23.9
condition 7 38 18.4
subroutine 19 45 42.2
pod 1 31 3.2
total 163 509 32.0


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