Date-Convert-French_Rev
view release on metacpan or search on metacpan
eg/r2g_table view on Meta::CPAN
# so we choose a random month.
if ($m == 6 || $m == 13)
{
my @m = qw(1 2 3 4 5 7 8 9 10 11 12);
$m = $m[11 * rand];
}
# First example
my $date = Date::Convert::French_Rev->new($y, $m, $d);
my $title_date = $date->date_string("%d %B %EY");
Date::Convert::Gregorian->convert($date);
my $y2 = sprintf "%02d", $y % 100;
my $part = $m <= 6 ? 'b' : 'e';
my $offset = $part eq 'e' ? 1792 : 1791;
my $letter = letter_of_yearpart($y, $part);
my $word = word_for_year($y);
my @formulas = formulas($y, $m);
my $limit = $1 if $formulas[1] =~ /(\d+)/;
my $formula = $formulas[$d <= $limit ? 0 : 1];
my $gyear = $date->year();
my $gmonth = $date->month();
my $gday = $date->day();
my $begint; # Beginning of the interval
foreach (sort { $a <=> $b } keys %end_of_interval)
{
last if $y < $_;
$begint = $_;
}
my $gr_date = &{$labels{format}}($gyear, $gmonth, $gday, $lang);
$_ = eval "qq($labels{usage3})";
print;
print "\n";
# Second example: Ventôse
# $m = 6;
$date = Date::Convert::French_Rev->new($y, 6, $d);
$title_date = $date->date_string("%d %B %EY");
Date::Convert::Gregorian->convert($date);
@formulas = formulas($y, 6);
my $bletter = letter_of_yearpart($y, 'b');
my $eletter = letter_of_yearpart($y, 'e');
$gyear = $date->year();
$gmonth = $date->month();
$gday = $date->day();
$gr_date = &{$labels{format}}($gyear, $gmonth, $gday, $lang);
$limit = $1 if $formulas[1] =~ /(\d+)/;
if ($d <= $limit)
{ $formula = $formulas[0]; $offset = 1791 }
else
{ $formula = $formulas[1]; $offset = 1792 }
$_ = eval "qq($labels{usage4})";
print;
}
__END__
=encoding utf8
=head1 NAME
r2g_table - Print a few charts which can be used to convert a date from the French Revolutionary calendar to the Gregorian calendar.
=head1 SYNOPSIS
r2g_table [--columns=I<nb>] [--example=I<date>] [--lang=I<language>] [--table-workaround]
=head1 DESCRIPTION
This program prints three tables, plus a small text showing how to use
these tables. The output uses UTF-8 encoding and HTML format. When
printed from a table-aware web browser, these tables allow a
computer-less user to convert dates from the French Revolutionary
calendar to the Gregorian calendar.
=head1 OPTIONS
=over 4
=item columns
The number of columns in the the first table. This must be a multiple
of 4, plus 1. With 5, you get a narrow table with many lines, while
with 13 or even 17, you get a wide table with fewer lines.
=item example
The instructions for use need a date as an example. The user can
select the date that will be used as an example (French Revolution
date, YYYYMMDD numeric format). Actually, the instructions use two
examples: the first one not in Ventôse, the second one in Ventôse. If
the user provides a date in Ventôse, the program will select a random
month for the first example.
=item lang
Select the language that will be used for all language-dependant
elements, including the instructions for use. Available languages are:
=over 4
=item en
English (default)
=item us
English, with the Gregorian dates formatted in the US way (December 1,
2001)
=item fr
French
=back
=item table-workaround
Kept for historical reasons.
Many years ago, around 2001 or 2002, I had noticed that when my web
browser rendered and printed tables, it had problems with plain text
following the tables, and it would skip a few plain text lines. In the
present case, the first lines of the instructions for use would
disappear. The workaround I had found consisted in building a table
around the instructions for use. This option triggers this workaround.
=back
=head1 AUTHOR
Jean Forget <JFORGET@cpan.org>
=head1 LICENSE
( run in 1.219 second using v1.01-cache-2.11-cpan-39bf76dae61 )