our
$VERSION
=
'0.900_04'
;
sub
_recalc_DateTime {
my
(
$self
,
%dt_args
) =
@_
;
my
(
$prevleap
,
$gregleap
,
$modyear
,
$yday
,
$arg
);
my
@monthlen
= (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$dt_args
{year} =
$self
->{year} - 5464;
$prevleap
= 0;
$prevleap
= 1
if
(((
$self
->{year} - 1) % 4 == 0) and ((
$self
->{year} - 1) % 100 != 0));
$prevleap
= 1
if
((
$self
->{year} - 1) % 400 == 0);
if
(
$self
->{holiday}) {
if
(
$self
->{leapyear}) {
$yday
= (0, 1, 182, 183, 184, 185, 366)[
$self
->{holiday}];
}
else
{
$yday
= (0, 1, 182, 183, 0, 184, 365)[
$self
->{holiday}];
}
}
else
{
$yday
= (
$self
->{month} - 1) * 30 +
$self
->{day} + 1;
$yday
+= 3
if
$yday
> 181;
++
$yday
if
$self
->{leapyear} and
$yday
> 183;
}
$yday
-= 9;
$modyear
=
$self
->{year} % 400;
if
((
$modyear
> 300) && (
$modyear
< 364)) {
--
$yday
;
}
elsif
(
$modyear
== 364) {
--
$yday
;
}
elsif
(((
$modyear
> 64) && (
$modyear
< 100)) || ((
$modyear
> 164) && (
$modyear
< 200))) {
++
$yday
;
}
elsif
((
$modyear
== 100) || (
$modyear
== 200)) {
++
$yday
;
}
if
(
$yday
< 1) {
--
$dt_args
{year};
$gregleap
= 0;
$gregleap
= 1
if
((
$dt_args
{year} % 4 == 0) and (
$dt_args
{year} % 100 != 0));
$gregleap
= 1
if
(
$dt_args
{year} % 400 == 0);
if
(
$gregleap
) {
$yday
+= 366;
}
else
{
$yday
+= 365;
}
}
else
{
$gregleap
= 0;
$gregleap
= 1
if
((
$dt_args
{year} % 4 == 0) and (
$dt_args
{year} % 100 != 0));
$gregleap
= 1
if
(
$dt_args
{year} % 400 == 0);
if
(
$gregleap
and
$yday
> 366) {
++
$dt_args
{year};
$yday
-= 366;
$gregleap
= 0;
}
elsif
(
$yday
> 365) {
++
$dt_args
{year};
$yday
-= 365;
$gregleap
= 0;
$gregleap
= 1
if
((
$dt_args
{year} % 4 == 0) and (
$dt_args
{year} % 100 != 0));
$gregleap
= 1
if
(
$dt_args
{year} % 400 == 0);
}
}
$monthlen
[2] = 29
if
$gregleap
;
$dt_args
{month} = 1;
while
(
$yday
>
$monthlen
[
$dt_args
{month}] and
$dt_args
{month} < 12) {
$yday
-=
$monthlen
[
$dt_args
{month}];
++
$dt_args
{month};
}
$dt_args
{day} =
$yday
;
if
(
$self
->{dt}) {
foreach
$arg
(
qw(hour minute second nanosecond time_zone locale)
) {
$dt_args
{
$arg
} =
$self
->{dt}->
$arg
if
not
defined
$dt_args
{
$arg
};
}
}
$self
->{dt} = new DateTime(
%dt_args
);
}
sub
_recalc_Shire {
my
$self
=
shift
;
my
(
$yday
,
$modyear
);
$self
->{year} =
$self
->{dt}->year + 5464;
$self
->{holiday} = 0;
$yday
=
$self
->{dt}->day_of_year + 9;
$modyear
=
$self
->{year} % 400;
if
((
$modyear
> 300) && (
$modyear
< 364)) {
++
$yday
;
}
elsif
(
$modyear
== 364) {
++
$yday
;
}
elsif
(((
$modyear
> 64) && (
$modyear
< 100)) || ((
$modyear
> 164) && (
$modyear
< 200))) {
--
$yday
;
}
elsif
((
$modyear
== 100) || (
$modyear
== 200)) {
--
$yday
;
}
$self
->{leapyear} = 0;
$self
->{leapyear} = 1
if
(
$self
->{year} % 4 == 0) and (
$self
->{year} % 100 != 0);
$self
->{leapyear} = 1
if
$self
->{year} % 400 == 0;
if
(
$self
->{leapyear} and
$yday
> 366) {
++
$self
->{year};
$yday
-= 366;
$self
->{leapyear} = 0;
}
elsif
(!
$self
->{leapyear} and
$yday
> 365) {
++
$self
->{year};
$yday
-= 365;
$self
->{leapyear} = 0;
$self
->{leapyear} = 1
if
(
$self
->{year} % 4 == 0) and (
$self
->{year} % 100 != 0);
$self
->{leapyear} = 1
if
$self
->{year} % 400 == 0;
}
if
(
$self
->{leapyear}) {
$self
->{holiday} = 4
if
(
$yday
== 184);
--
$yday
if
$yday
> 184;
}
unless
(
$self
->{holiday}) {
if
(
$yday
== 1) {
$self
->{holiday} = 1;}
elsif
(
$yday
== 182) {
$self
->{holiday} = 2;}
elsif
(
$yday
== 183) {
$self
->{holiday} = 3;}
elsif
(
$yday
== 184) {
$self
->{holiday} = 5;}
elsif
(
$yday
== 365) {
$self
->{holiday} = 6;}
}
--
$yday
if
$yday
> 183;
if
(
$self
->{holiday} == 3 or
$self
->{holiday} == 4) {
$self
->{wday} = 0;
}
else
{
$self
->{wday} = ((
$yday
- 1) % 7) + 1;
}
if
(
$self
->{holiday}) {
$self
->{month} = 0;
$self
->{day} = 0;
}
else
{
--
$yday
;
$yday
-= 2
if
$yday
> 180;
$self
->{day} = ((
$yday
- 1) % 30) + 1;
$self
->{month} =
int
((
$yday
- 1) / 30) + 1;
}
$self
->{recalc} = 0;
}
sub
new {
my
(
$class
,
%args
) =
@_
;
my
(
$self
,
$arg
,
%dt_args
,
$itr
);
my
@months
= (
''
,
'Afteryule'
,
'Solmath'
,
'Rethe'
,
'Astron'
,
'Thrimidge'
,
'Forelithe'
,
'Afterlithe'
,
'Wedmath'
,
'Halimath'
,
'Winterfilth'
,
'Blotmath'
,
'Foreyule'
);
my
@holidays
= (
''
,
'2 Yule'
,
'1 Lithe'
,
"Midyear's day"
, 'Overlithe
', '
2 Lithe
', '
1 Yule');
if
(
$args
{month}) {
foreach
$itr
(1..12) {
$args
{month} =
$itr
if
$args
{month} eq
$months
[
$itr
];
}
}
if
(
$args
{holiday}) {
foreach
$itr
(1..6) {
$args
{holiday} =
$itr
if
$args
{holiday} eq
$holidays
[
$itr
];
}
}
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid year given to new constructor\n"
if
not
int
(
$args
{year});
$self
->{year} =
$args
{year};
$self
->{leapyear} = 0;
$self
->{leapyear} = 1
if
$self
->{year} % 4 == 0 and
$self
->{year} % 100 != 0;
$self
->{leapyear} = 1
if
$self
->{year} % 400 == 0;
if
(
$args
{holiday}) {
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid holiday given to new constructor\n"
if
(
int
(
$args
{holiday}) < 0) || (
int
(
$args
{holiday}) > 6);
die
"DateTime::Fiction::JRRTolkien::Shire: Overlithe is only valid on leap years\n"
if
$args
{holiday} == 4 and not
$self
->{leapyear};
$self
->{holiday} =
$args
{holiday};
}
elsif
(
$args
{month}) {
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid month given to new constructor\n"
if
(
int
(
$args
{month}) < 1) || (
int
(
$args
{month}) > 12);
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid day given to new constructor\n"
if
$args
{day} and (
int
(
$args
{day}) < 1) || (
int
(
$args
{day}) > 30);
$self
->{month} =
$args
{month};
$self
->{day} =
$args
{day} || 1;
}
else
{
$self
->{holiday} = 1;
}
foreach
$arg
(
qw(hour minute second nanosecond time_zone locale)
) {
$dt_args
{
$arg
} =
$args
{
$arg
}
if
defined
$args
{
$arg
};
}
$self
->{recalc} = 1;
bless
$self
,
$class
;
$self
->_recalc_DateTime(
%dt_args
);
return
$self
;
}
sub
from_epoch {
my
(
$class
,
%args
) =
@_
;
my
$self
;
$self
->{dt} = DateTime->from_epoch(
%args
);
$self
->{recalc} = 1;
return
bless
$self
,
$class
;
}
sub
now {
my
(
$class
,
%args
) =
@_
;
my
$self
;
$self
->{dt} = DateTime->now(
%args
);
$self
->{recalc} = 1;
return
bless
$self
,
$class
;
}
sub
today {
my
(
$class
,
%args
) =
@_
;
my
$self
;
$self
->{dt} = DateTime->today(
%args
);
$self
->{recalc} = 1;
return
bless
$self
,
$class
;
}
sub
from_object {
my
(
$class
,
%args
) =
@_
;
my
$self
;
$self
->{dt} = DateTime->from_object(
%args
);
$self
->{recalc} = 1;
return
bless
$self
,
$class
;
}
sub
last_day_of_month {
my
(
$class
,
%args
) =
@_
;
$args
{day} = 30;
return
$class
->new(
%args
);
}
sub
from_day_of_year {
my
(
$class
,
%args
) =
@_
;
my
(
$doy
,
$self
,
$leap
);
$doy
=
$args
{day_of_year};
delete
$args
{day_of_year};
die
"DateTime::Fiction::JRRTolkien::Shire: No year given to from_day_of_year constructor.\n"
if
not
$args
{year};
$leap
= 1
if
$args
{year} % 4 == 0 and
$args
{year} % 100 != 0;
$leap
= 1
if
$args
{year} % 400 == 0;
if
(
$leap
) {
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid day given to from_day_of_year constructor.\n"
if
$doy
> 366 or
$doy
< 1;
if
(
$doy
== 1) {
$args
{holiday} = 1;
}
elsif
(
$doy
== 182) {
$args
{holiday} = 2;
}
elsif
(
$doy
== 183) {
$args
{holiday} = 3;
}
elsif
(
$doy
== 184) {
$args
{holiday} = 4;
}
elsif
(
$doy
== 185) {
$args
{holiday} = 5;
}
elsif
(
$doy
== 366) {
$args
{holiday} = 6;
}
else
{
$doy
-= 4
if
$doy
> 185;
--
$doy
;
$args
{month} =
int
((
$doy
- 1) / 30) + 1;
$args
{day} = ((
$doy
- 1) % 30) + 1;
}
}
else
{
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid day given to from_day_of_year constructor.\n"
if
$doy
> 365 or
$doy
< 1;
if
(
$doy
== 1) {
$args
{holiday} = 1;
}
elsif
(
$doy
== 182) {
$args
{holiday} = 2;
}
elsif
(
$doy
== 183) {
$args
{holiday} = 3;
}
elsif
(
$doy
== 184) {
$args
{holiday} = 5;
}
elsif
(
$doy
== 365) {
$args
{holiday} = 6;
}
else
{
$doy
-= 3
if
$doy
> 184;
--
$doy
;
$args
{month} =
int
((
$doy
- 1) / 30) + 1;
$args
{day} = ((
$doy
- 1) % 30) + 1;
}
}
return
$class
->new(
%args
);
}
sub
clone {
bless
{ %{
$_
[0] } },
ref
$_
[0] }
sub
year {
my
$self
=
shift
;
$self
->_recalc_Shire
if
$self
->{recalc};
return
$self
->{year};
}
sub
month {
my
$self
=
shift
;
$self
->_recalc_Shire
if
$self
->{recalc};
return
$self
->{month};
}
sub
month_name {
my
$self
=
shift
;
my
@months
= (
''
,
'Afteryule'
,
'Solmath'
,
'Rethe'
,
'Astron'
,
'Thrimidge'
,
'Forelithe'
,
'Afterlithe'
,
'Wedmath'
,
'Halimath'
,
'Winterfilth'
,
'Blotmath'
,
'Foreyule'
);
return
$months
[
$self
->month];
}
sub
day_of_month {
my
$self
=
shift
;
$self
->_recalc_Shire
if
$self
->{recalc};
return
$self
->{day};
}
sub
day {
return
$_
[0]->day_of_month; }
sub
mday {
return
$_
[0]->day_of_month; }
sub
day_of_week {
my
$self
=
shift
;
$self
->_recalc_Shire
if
$self
->{recalc};
return
$self
->{wday};
}
sub
wday {
return
$_
[0]->day_of_week; }
sub
dow {
return
$_
[0]->day_of_week; }
sub
day_name {
my
$self
=
shift
;
my
@days
= (
''
,
'Sterday'
,
'Sunday'
,
'Monday'
,
'Trewsday'
,
'Hevensday'
,
'Mersday'
,
'Highday'
);
return
$days
[
$self
->day_of_week];
}
sub
day_name_trad {
my
$self
=
shift
;
my
@days
= (
''
,
'Sterrendei'
,
'Sunnendei'
,
'Monendei'
,
'Trewesdei'
,
'Hevenesdei'
,
'Meresdei'
,
'Highdei'
);
return
$days
[
$self
->day_of_week];
}
sub
holiday {
my
$self
=
shift
;
$self
->_recalc_Shire
if
$self
->{recalc};
return
$self
->{holiday};
}
sub
holiday_name {
my
$self
=
shift
;
my
@holidays
= (
''
,
'2 Yule'
,
'1 Lithe'
,
"Midyear's day"
, 'Overlithe
', '
2 Lithe
', '
1 Yule');
return
$holidays
[
$self
->holiday];
}
sub
is_leap_year {
my
$self
=
shift
;
$self
->_recalc_Shire
if
$self
->{recalc};
return
$self
->{leapyear};
}
sub
day_of_year {
my
$self
=
shift
;
my
$yday
;
$self
->_recalc_Shire
if
$self
->{recalc};
if
(
$self
->{month}) {
$yday
= 30 * (
$self
->{month} - 1) +
$self
->{day} + 1;
if
(
$self
->{month} > 6) {
$yday
+= 3;
++
$yday
if
$self
->{leapyear};
}
}
else
{
if
(
$self
->{leapyear}) {
$yday
= (0, 1, 182, 183, 184, 185, 366)[
$self
->{holiday}];
}
else
{
$yday
= (0, 1, 182, 183, 0, 184, 365)[
$self
->{holiday}];
}
}
return
$yday
;
}
sub
doy {
return
$_
[0]->day_of_year };
sub
week {
return
(
$_
[0]->week_year,
$_
[0]->week_number); }
sub
week_year {
return
$_
[0]->year; }
sub
week_number {
my
$self
=
shift
;
my
$yday
=
$self
->day_of_year;
183 ==
$yday
and
return
0;
184 ==
$yday
and
$self
->is_leap_year
and
return
0;
--
$yday
if
$yday
> 182;
--
$yday
if
$yday
> 182 and
$self
->is_leap_year;
return
int
((
$yday
- 1) / 7) + 1;
}
sub
epoch {
return
$_
[0]->{dt}->epoch; }
sub
hires_epoch {
return
$_
[0]->{dt}->hires_epoch; }
sub
utc_rd_values {
return
$_
[0]->{dt}->utc_rd_values; }
sub
utc_rd_as_seconds {
return
$_
[0]->{dt}->utc_rd_as_seconds; }
sub
set {
my
(
$self
,
%args
) =
@_
;
my
(
%dt_args
,
$arg
,
$itr
);
my
@months
= (
''
,
'Afteryule'
,
'Solmath'
,
'Rethe'
,
'Astron'
,
'Thrimidge'
,
'Forelithe'
,
'Afterlithe'
,
'Wedmath'
,
'Halimath'
,
'Winterfilth'
,
'Blotmath'
,
'Foreyule'
);
my
@holidays
= (
''
,
'2 Yule'
,
'1 Lithe'
,
"Midyear's day"
, 'Overlithe
', '
2 Lithe
', '
1 Yule');
$self
->_recalc_Shire
if
$self
->{recalc};
if
(
$args
{month}) {
foreach
$itr
(1..12) {
$args
{month} =
$itr
if
$args
{month} eq
$months
[
$itr
];
}
}
if
(
$args
{holiday}) {
foreach
$itr
(1..6) {
$args
{holiday} =
$itr
if
$args
{holiday} eq
$holidays
[
$itr
];
}
}
$self
->{year} =
$args
{year} ||
$self
->{year};
$self
->{leapyear} = 0;
$self
->{leapyear} = 1
if
$self
->{year} % 4 == 0 and
$self
->{year} % 100 != 0;
$self
->{leapyear} = 1
if
$self
->{year} % 400 == 0;
if
(
$self
->{holiday}) {
if
(
$args
{holiday}) {
$self
->{holiday} =
$args
{holiday};
}
else
{
$self
->{holiday} = 0;
$self
->{month} =
$args
{month} || 1;
$self
->{day} =
$args
{day} || 1;
}
}
else
{
if
(
$args
{holiday}) {
$self
->{holiday} =
$args
{holiday};
$self
->{month} = 0;
$self
->{day} = 0;
}
else
{
$self
->{month} =
$args
{month} ||
$self
->{month};
$self
->{day} =
$args
{day} ||
$self
->{day};
}
}
if
(
$self
->{holiday}) {
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid holiday given to set method\n"
if
(
int
(
$self
->{holiday}) < 0) || (
int
(
$self
->{holiday}) > 6);
die
"DateTime::Fiction::JRRTolkien::Shire: Overlithe is only valid on a leap year\n"
if
$self
->{holiday} == 4 and not
$self
->{leapyear};
}
else
{
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid month given to set method\n"
if
(
int
(
$self
->{month}) < 1) || (
int
(
$self
->{month}) > 12);
die
"DateTime::Fiction::JRRTolkien::Shire: Invalid day given to set method\n"
if
(
int
(
$self
->{day}) < 1) || (
int
(
$self
->{day}) > 30);
}
foreach
$arg
(
qw(hour minute second nanosecond locale)
) {
$dt_args
{
$arg
} =
$args
{
$arg
}
if
defined
$args
{
$arg
};
}
$self
->_recalc_DateTime(
%dt_args
);
$self
->{recalc} = 1;
return
$self
;
}
sub
truncate
{
my
(
$self
,
%args
) =
@_
;
my
(
$info
,
%greg
);
$self
->_recalc_Shire
if
$self
->{recalc};
if
(
$args
{to} eq
'year'
) {
$self
->set(
year
=>
$self
->{year},
holiday
=> 1,
hour
=> 0,
minute
=> 0,
second
=> 0,
nanosecond
=> 0);
}
elsif
(
$args
{to} eq
'month'
) {
if
(
$self
->{holiday}) {
$self
->{dt}->
truncate
(
to
=>
'day'
);
}
else
{
$self
->set(
year
=>
$self
->{year},
month
=>
$self
->{month},
day
=> 1,
hour
=> 0,
minute
=> 0,
second
=> 0,
nanosecond
=> 0);
}
}
else
{
$self
->{dt}->
truncate
(
to
=>
'day'
);
}
return
$self
;
}
sub
set_time_zone {
my
(
$self
,
$tz
) =
@_
;
$self
->{dt}->set_time_zone(
$tz
);
$self
->{recalc} = 1;
}
sub
compare {
return
$_
[0]->{dt} <=>
$_
[1]->{dt}; }
sub
stringify {
my
$self
=
shift
;
my
$returntext
;
$self
->_recalc_Shire
if
$self
->{recalc};
if
(
$self
->{holiday}) {
if
(
$self
->{wday}) {
$returntext
=
$self
->day_name .
" "
.
$self
->holiday_name .
" "
.
$self
->{year};
}
else
{
$returntext
=
$self
->holiday_name .
" "
.
$self
->{year};
}
}
else
{
$returntext
=
$self
->day_name .
" "
.
$self
->{day} .
" "
.
$self
->month_name .
" "
.
$self
->{year};
}
return
$returntext
;
}
sub
on_date {
my
$self
=
shift
;
my
(
$returntext
,
%events
);
$self
->_recalc_Shire
if
$self
->{recalc};
$events
{0} = {
3
=>
"Wedding of King Elessar and Arwen, 1419.\n"
};
$events
{1} = {
8
=>
"The Company of the Ring reaches Hollin, 1419.\n"
,
13
=>
"The Company of the Ring reaches the West-gate of Moria at nightfall, 1419.\n"
,
14
=>
"The Company of the Ring spends the night in Moria Hall 21, 1419.\n"
,
15
=>
"The Bridge of Khazad-dum, and fall of Gandalf, 1419.\n"
,
17
=>
"The Company of the Ring comes to Caras Galadhon at evening, 1419.\n"
,
23
=>
"Gandalf pursues the Balrog to the peak of Zirakzigil, 1419.\n"
,
25
=>
"Gandalf casts down the Balrog, and passes away.\n"
.
"His body lies on the peak of Zirakzigil, 1419.\n"
};
$events
{2} = {
14
=>
"Frodo and Sam look in the Mirror of Galadriel, 1419.\n"
.
"Gandalf returns to life, and lies in a trance, 1419.\n"
,
16
=>
"Company of the Ring says farewell to Lorien --\n"
.
"Gollum observes departure, 1419.\n"
,
17
=>
"Gwaihir the eagle bears Gandalf to Lorien, 1419.\n"
,
25
=>
"The Company of the Ring pass the Argonath and camp at Parth Galen, 1419.\n"
.
"First battle of the Fords of Isen -- Theodred son of Theoden slain, 1419.\n"
,
26
=>
"Breaking of the Fellowship, 1419.\n"
.
"Death of Boromir; his horn is heard in Minas Tirith, 1419.\n"
.
"Meriadoc and Peregrin captured by Orcs -- Aragorn pursues, 1419.\n"
.
"Eomer hears of the descent of the Orc-band from Emyn Muil, 1419.\n"
.
"Frodo and Samwise enter the eastern Emyn Muil, 1419.\n"
,
27
=>
"Aragorn reaches the west-cliff at sunrise, 1419.\n"
.
"Eomer sets out from Eastfold against Theoden's orders to pursue the Orcs, 1419.\n"
,
28
=>
"Eomer overtakes the Orcs just outside of Fangorn Forest, 1419.\n"
,
29
=>
"Meriadoc and Pippin escape and meet Treebeard, 1419.\n"
.
"The Rohirrim attack at sunrise and destroy the Orcs, 1419.\n"
.
"Frodo descends from the Emyn Muil and meets Gollum, 1419.\n"
.
"Faramir sees the funeral boat of Boromir, 1419.\n"
,
30
=>
"Entmoot begins, 1419.\n"
.
"Eomer, returning to Edoras, meets Aragorn, 1419.\n"
};
$events
{3} = {
1
=>
"Aragorn meets Gandalf the White, and they set out for Edoras, 1419.\n"
.
"Faramir leaves Minas Tirith on an errand to Ithilien, 1419.\n"
,
2
=>
"The Rohirrim ride west against Saruman, 1419.\n"
.
"Second battle at the Fords of Isen; Erkenbrand defeated, 1419.\n"
.
"Entmoot ends. Ents march on Isengard and reach it at night, 1419.\n"
,
3
=>
"Theoden retreats to Helm's Deep; battle of the Hornburg begins, 1419.\n"
.
"Ents complete the destruction of Isengard.\n"
,
4
=>
"Theoden and Gandalf set out from Helm's Deep for Isengard, 1419.\n"
.
"Frodo reaches the slag mound on the edge of the of the Morannon, 1419.\n"
,
5
=>
"Theoden reaches Isengard at noon; parley with Saruman in Orthanc, 1419.\n"
.
"Gandalf sets out with Peregrin for Minas Tirith, 1419.\n"
,
6
=>
"Aragorn overtaken by the Dunedain in the early hours, 1419.\n"
,
7
=>
"Frodo taken by Faramir to Henneth Annun, 1419.\n"
.
"Aragorn comes to Dunharrow at nightfall, 1419.\n"
,
8
=>
"Aragorn takes the \"Paths of the Dead\", and reaches Erech at midnight, 1419.\n"
.
"Frodo leaves Henneth Annun, 1419.\n"
,
9
=>
"Gandalf reaches Minas Tirith, 1419.\n"
.
"Darkness begins to flow out of Mordor, 1419.\n"
,
10
=>
"The Dawnless Day, 1419.\n"
.
"The Rohirrim are mustered and ride from Harrowdale, 1419.\n"
.
"Faramir rescued by Gandalf at the gates of Minas Tirith, 1419.\n"
.
"An army from the Morannon takes Cair Andros and passes into Anorien, 1419.\n"
,
11
=>
"Gollum visits Shelob, 1419.\n"
.
"Denethor sends Faramir to Osgiliath, 1419.\n"
.
"Eastern Rohan is invaded and Lorien assaulted, 1419.\n"
,
12
=>
"Gollum leads Frodo into Shelob's lair, 1419.\n"
.
"Ents defeat the invaders of Rohan, 1419.\n"
,
13
=>
"Frodo captured by the Orcs of Cirith Ungol, 1419.\n"
.
"The Pelennor is overrun and Faramir is wounded, 1419.\n"
.
"Aragorn reaches Pelargir and captures the fleet of Umbar, 1419.\n"
,
14
=>
"Samwise finds Frodo in the tower of Cirith Ungol, 1419.\n"
.
"Minas Tirith besieged, 1419.\n"
,
15
=>
"Witch King breaks the gates of Minas Tirith, 1419.\n"
.
"Denethor, Steward of Gondor, burns himself on a pyre, 1419.\n"
.
"The battle of the Pelennor occurs as Theoden and Aragorn arrive, 1419.\n"
.
"Thranduil repels the forces of Dol Guldur in Mirkwood, 1419.\n"
.
"Lorien assaulted for second time, 1419.\n"
,
17
=>
"Battle of Dale, where King Brand and King Dain Ironfoot fall, 1419.\n"
.
"Shagrat brings Frodo's cloak, mail-shirt, and sword to Barad-dur, 1419.\n"
,
18
=>
"Host of the west leaves Minas Tirith, 1419.\n"
.
"Frodo and Sam overtaken by Orcs on the road from Durthang to Udun, 1419.\n"
,
19
=>
"Frodo and Sam escape the Orcs and start on the road toward Mount Doom, 1419.\n"
,
22
=>
"Lorien assaulted for the third time, 1419.\n"
,
24
=>
"Frodo and Sam reach the base of Mount Doom, 1419.\n"
,
25
=>
"Battle of the Host of the West on the slag hill of the Morannon, 1419.\n"
.
"Gollum siezes the Ring of Power and falls into the Cracks of Doom, 1419.\n"
.
"Downfall of Barad-dur and the passing of Sauron!, 1419.\n"
.
"Birth of Elanor the Fair, daughter of Samwise, 1421.\n"
.
"Fourth age begins in the reckoning of Gondor, 1421.\n"
,
27
=>
"Bard II and Thorin III Stonehelm drive the enemy from Dale, 1419.\n"
,
28
=>
"Celeborn crosses the Anduin and begins destruction of Dol Guldur, 1419.\n"
};
$events
{4} = {
6
=>
"The mallorn tree flowers in the Party Field, 1420.\n"
,
8
=>
"Ring bearers are honored on the Field of Cormallen, 1419.\n"
,
12
=>
"Gandalf arrives in Hobbiton, 1418\n"
};
$events
{5} = {
1
=>
"Crowning of King Elessar, 1419.\n"
.
"Samwise marries Rose, 1420.\n"
};
$events
{6} = {
20
=>
"Sauron attacks Osgiliath, 1418.\n"
.
"Thranduil is attacked, and Gollum escapes, 1418.\n"
};
$events
{7} = {
4
=>
"Boromir sets out from Minas Tirith, 1418\n"
,
10
=>
"Gandalf imprisoned in Orthanc, 1418\n"
,
19
=>
"Funeral Escort of King Theoden leaves Minas Tirith, 1419.\n"
};
$events
{8} = {
10
=>
"Funeral of King Theoden, 1419.\n"
};
$events
{9} = {
18
=>
"Gandalf escapes from Orthanc in the early hours, 1418.\n"
,
19
=>
"Gandalf comes to Edoras as a beggar, and is refused admittance, 1418\n"
,
20
=>
"Gandalf gains entrance to Edoras. Theoden commands him to go:\n"
.
"\"Take any horse, only be gone ere tomorrow is old\", 1418.\n"
,
21
=>
"The hobbits return to Rivendell, 1419.\n"
,
22
=>
"Birthday of Bilbo and Frodo.\n"
.
"The Black Riders reach Sarn Ford at evening;\n"
.
" they drive off the guard of Rangers, 1418.\n"
.
"Saruman comes to the Shire, 1419.\n"
,
23
=>
"Four Black Riders enter the shire before dawn. The others pursue \n"
.
"the Rangers eastward and then return to watch the Greenway, 1418.\n"
.
"A Black Rider comes to Hobbiton at nightfall, 1418.\n"
.
"Frodo leaves Bag End, 1418.\n"
.
"Gandalf having tamed Shadowfax rides from Rohan, 1418.\n"
,
26
=>
"Frodo comes to Bombadil, 1418\n"
,
28
=>
"The Hobbits are captured by a barrow-wight, 1418.\n"
,
29
=>
"Frodo reaches Bree at night, 1418.\n"
.
"Frodo and Bilbo depart over the sea with the three Keepers, 1421.\n"
.
"End of the Third Age, 1421.\n"
,
30
=>
"Crickhollow and the inn at Bree are raided in the early hours, 1418.\n"
.
"Frodo leaves Bree, 1418.\n"
,
};
$events
{10} = {
3
=>
"Gandalf attacked at night on Weathertop, 1418.\n"
,
5
=>
"Gandalf and the Hobbits leave Rivendell, 1419.\n"
,
6
=>
"The camp under Weathertop is attacked at night and Frodo is wounded, 1418.\n"
,
11
=>
"Glorfindel drives the Black Riders off the Bridge of Mitheithel, 1418.\n"
,
13
=>
"Frodo crosses the Bridge of Mitheithel, 1418.\n"
,
18
=>
"Glorfindel finds Frodo at dusk, 1418.\n"
.
"Gandalf reaches Rivendell, 1418.\n"
,
20
=>
"Escape across the Ford of Bruinen, 1418.\n"
,
24
=>
"Frodo recovers and wakes, 1418.\n"
.
"Boromir arrives at Rivendell at night, 1418.\n"
,
25
=>
"Council of Elrond, 1418.\n"
,
30
=>
"The four Hobbits arrive at the Brandywine Bridge in the dark, 1419.\n"
};
$events
{11} = {
3
=>
"Battle of Bywater and passing of Saruman, 1419.\n"
.
"End of the War of the Ring, 1419.\n"
};
$events
{12} = {
25
=>
"The Company of the Ring leaves Rivendell at dusk, 1418.\n"
};
if
(
$self
->{holiday} and
defined
(
$events
{0}->{
$self
->{holiday}})) {
$returntext
.=
"$self\n\n"
.
$events
{0}->{
$self
->{holiday}};
}
elsif
(
defined
(
$events
{
$self
->{month}}->{
$self
->{day}})) {
$returntext
.=
"$self\n\n"
.
$events
{
$self
->{month}}->{
$self
->{day}};
}
else
{
$returntext
=
"$self\n"
;
}
return
$returntext
;
}