DateTime-Calendar-FrenchRevolutionary

 view release on metacpan or  search on metacpan

eg/g2r_table  view on Meta::CPAN

    }

  # First example
  my $gr_date  = &{$labels{format}}($y, $m, $d, $lang);
  #my $date = new Date::Convert::Gregorian $y, $m, $d;
  #convert Date::Convert::FrenchRevolutionary $date;
  my $date = DateTime::Calendar::FrenchRevolutionary->from_object(object => DateTime->new(year => $y, month => $m, day => $d));
  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->strftime("%e %b");
  my $rev_date  = $date->strftime("%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 = new Date::Convert::Gregorian $y, 9, $d;
  #convert Date::Convert::FrenchRevolutionary $date;
  $date = DateTime::Calendar::FrenchRevolutionary->from_object(object => DateTime->new(year => $y, month => 9, day => $d));
  @formulas   = formulas($y, 9);
  my $mletter = letter_of_yearpart($y, 'm');
  my $eletter = letter_of_yearpart($y, 'e');
  $abridged   = $date->strftime("%e %b %Y");
  $rev_date   = $date->strftime("%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

I have noticed that when my  web browser renders and prints tables, it
has problems with plain text following the tables, and it might skip a
few plain  text lines.  In  the present case,  the first lines  of the
instructions for use disappear.   The workaround I have found consists
in  building a  table around  the  instructions for  use. This  option
triggers this workaround.

=back

=head1 AUTHOR

Jean Forget <JFORGET@cpan.org>

=head1 LICENSE STUFF



( run in 0.825 second using v1.01-cache-2.11-cpan-995e09ba956 )