DateTime-Calendar-FrenchRevolutionary

 view release on metacpan or  search on metacpan

eg/r2g_table  view on Meta::CPAN

    }

  # First example
  #my $date = new Date::Convert::French_Rev $y, $m, $d;
  #convert Date::Convert::Gregorian $date;
  my $date_r   = DateTime::Calendar::FrenchRevolutionary->new(year => $y, month => $m, day => $d);
  my $date_g   = DateTime->from_object(object => $date_r);
  my $title_date = $date_r->strftime("%d %B %EY");
  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_g->year;
  my $gmonth   = $date_g->month;
  my $gday     = $date_g->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 = new Date::Convert::French_Rev $y, 6, $d;
  #$title_date = $date->date_string("%d %B %EY");
  #convert Date::Convert::Gregorian $date;
  $date_r   = DateTime::Calendar::FrenchRevolutionary->new(year => $y, month => 6, day => $d);
  $date_g   = DateTime->from_object(object => $date_r);
  $title_date = $date_r->strftime("%d %B %EY");
  @formulas   = formulas($y, 6);
  my $bletter = letter_of_yearpart($y, 'b');
  my $eletter = letter_of_yearpart($y, 'e');
  $gyear      = $date_g->year;
  $gmonth     = $date_g->month;
  $gday       = $date_g->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

I have noticed that when one of the web browsers I use renders 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

Copyright  (c) 2003,  2004, 2010,  2012, 2014,  2016, 2019,  2021 Jean



( run in 1.438 second using v1.01-cache-2.11-cpan-5735350b133 )