Date-Convert-French_Rev

 view release on metacpan or  search on metacpan

eg/g2r_table  view on Meta::CPAN

      my @m = qw(1 3 4 5 6 7 8 10 11 12);
      $m = $m[10 * rand];
    }

  # First example
  my $gr_date  = &{$labels{format}}($y, $m, $d, $lang);
  my $date = Date::Convert::Gregorian->new($y, $m, $d);
  Date::Convert::French_Rev->convert($date);
  my $y2       = sprintf "%02d", $y % 100;
  my $part     = $m <= 2 ? 'b' : $m < 9 ? 'm' : 'e';
  my $offset   = $part eq 'e' ? 1791 : 1792;
  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 $ryear    = $date->year();
  my $begint; # Beginning of the interval
  foreach (sort { $a <=> $b } keys %end_of_interval)
    {
      last if $y < $_;
      $begint = $_;
    }
  my $abridged  = $date->date_string("%e %b");
  my $rev_date  = $date->date_string("%A %e %B %EY");
  $_ = eval "qq($labels{usage1})";
  print;
  print "\n";

  # Second example: September
  # $m = 9;
  $gr_date  = &{$labels{format}}($y, 9, $d, $lang);
  $date = Date::Convert::Gregorian->new($y, 9, $d);
  Date::Convert::French_Rev->convert($date);
  @formulas   = formulas($y, 9);
  my $mletter = letter_of_yearpart($y, 'm');
  my $eletter = letter_of_yearpart($y, 'e');
  $abridged   = $date->date_string("%e %b %Y");
  $rev_date   = $date->date_string("%A %e %B %EY");
  $limit = $1 if $formulas[1] =~ /(\d+)/;
  if ($d <= $limit)
    { $formula = $formulas[0]; $offset = 1792 }
  else
    {
      $limit = $1 if $formulas[2] =~ /(\d+)/;
      if ($d <= $limit)
        { $formula = $formulas[1]; $offset = 1792 }
      else
        { $formula = $formulas[2]; $offset = 1791 }
    }
  $_ = eval "qq($labels{usage2})";
  print;
}

__END__

=encoding utf8

=head1 NAME

g2r_table -  Print a few  charts which can  be used to convert  a date from the Gregorian calendar to the French Revolutionary calendar.

=head1 SYNOPSIS

g2r_table [--columns=I<number>] [--example=I<date>] [--lang=I<language>] [--table-workaround]

=head1 DESCRIPTION

This program prints five 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 Gregorian calendar to the
French Revolutionary calendar.

=head1 OPTIONS

=over 4

=item columns

The  number of  columns in  the first  table.  This  number must  be a
multiple of 4  (because of the 4-year quasi-cycle  for leap days) plus
one (for the first line, giving  year intervals). So you can choose 5,
9,  13 or  17.  Higher number  are  allowed, but  they  will not  give
beutiful results.

=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  (Gregorian date,
YYYYMMDD numeric format). Actually, the instructions use two examples:
the first one  not in September, the second one  in September.  If the
user provides  a date in September,  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.

=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>



( run in 1.002 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )