Date-Convert-French_Rev
view release on metacpan or search on metacpan
eg/labels_en view on Meta::CPAN
# -*- encoding: utf-8; indent-tabs-mode: nil -*-
#
# English speaking labels for g2r_table, r2g_table and prt_cal
# Copyright (C) 2001, 2002, 2003, 2013, 2015, 2020 Jean Forget
#
# This program is distributed under the same terms as Perl 5.16.3:
# GNU Public License version 1 or later and Perl Artistic License
#
# You can find the text of the licenses in the F<LICENSE> file or at
# L<https://dev.perl.org/licenses/artistic.html>
# and L<https://www.gnu.org/licenses/gpl-1.0.html>.
#
# Here is the summary of GPL:
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 1, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., <https://www.fsf.org/>.
#
#
# The labels hash, under an assumed name
#
use utf8;
use strict;
use warnings;
my %labels =
( calendar => 'Calendar'
, month3 => [ qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) ]
, week1 => [ qw(M T W T F S S) ]
, add_days => 'Additional Days'
, month => [ qw(January February March April May June July August September
October November December) ]
, title1 => "Year to letter"
, title2 => { b => "Beginning of Year", m => "Middle of Year", e => "End of Year" }
, title3 => "Month names and day names"
, year_ttl => "Year"
, titleg2r => "Converting dates from Gregorian to French Revolutionary"
, titler2g => "Converting dates from French Revolutionary to Gregorian"
);
#
# Formatting a Gregorian date
#
$labels{format} = sub {
my ($y, $m, $d, $l) = @_;
return "$d $labels{month}[$m-1] $y" if ($l eq 'en');
return "$labels{month}[$m-1] $d, $y"
};
#
# Instructions for use, for greg to rev
#
$labels{usage1} = <<'EOT';
<h3>How to convert $gr_date</h3>
<p>Look at the first table. The Gregorian year <strong>$y</strong> belongs to the interval
<em>$begint - $end_of_interval{$begint}</em> and its last two digits are
<em>$y2</em>.
The cell in the corresponding
line and column contains the three letters <em>$word</em>.
<p>Look at the next three tables.
The month <strong>$labels{month}[$m-1]</strong> appears in the <em>$labels{title2}{$part}</em> table, at
the head of which is the fomula <em>$labels{year_ttl} - $offset</em>.
So you can compute that the French Revolutionary year is <strong>$ryear</strong>.
Of the three letters <em>$word</em>, the letter <em>$letter</em> appears
in the same table. The corresponding cell contains two formulas:
<em>@formulas</em>. Choose the one that will convert the day number <strong>$d</strong>
into a number in the 1-30 range. That is, up to and including
<strong>$limit $labels{month}[$m - 1]</strong>, use
the first formula <em>$formulas[0]</em>, and later use the second formula <em>$formulas[1]</em>.
Since the Gregorian day number is <strong>$d</strong>, you use <em>$formula</em>, and you get
<strong>$abridged</strong>. The final step consists in retrieving the day's full name
and the month's full name in the last table, which gives
<strong>$rev_date</strong>.
EOT
$labels{usage2} = <<'EOT';
<h3>How to convert $gr_date</h3>
<p>What about September? The first step is the same, and gives the same three letters
<em>$word</em>.
<p>But <strong>$labels{month}[8]</strong>
appears both in the
<em>$labels{title2}{m}</em>
table, and in the
<em>$labels{title2}{e}</em>
table. The first one gives two formulas for the day:
<em>$formulas[0]</em>
and
( run in 2.097 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )