Advanced-Config
view release on metacpan or search on metacpan
lib/Advanced/Config/Date.pm view on Meta::CPAN
# Always keep the keys in lower case.
# Using the values from Date::Language::English for initialization ...
# Hard coded here in case Date::Language wasn't installed ...
# These hashes get rebuilt each time swap_language() is
# successfully called!
# ========================================================================
# Used by parse_date ();
my %last_language_edit_flags;
# Variants for the month names & days of month ...
# We hard code the initialization in case neither
# language module is installed locally.
my %Months;
my %Days;
BEGIN {
# Variants for the month names ...
%Months = (
# The USA Months spelled out ...
# Built from the @Date::Language::English::MoY array ...
"january" => 1, "february" => 2, "march" => 3,
"april" => 4, "may" => 5, "june" => 6,
"july" => 7, "august" => 8, "september" => 9,
"october" => 10, "november" => 11, "december" => 12,
# The USA Months using 3 char abreviations ("may" not repeated!)
# Built from the @Date::Language::English::MoYs array ...
"jan" => 1, "feb" => 2, "mar" => 3, "apr" => 4,
"jun" => 6, "jul" => 7, "aug" => 8,
"sep" => 9, "oct" => 10, "nov" => 11, "dec" => 12,
# Months as a numeric value. If all digits, leading zeros will
# be removed before it's used as a key.
"1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5, "6" => 6,
"7" => 7, "8" => 8, "9" => 9, "10" => 10, "11" => 11, "12" => 12
);
# variants for days of the month ...
%Days = (
"1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5,
"6" => 6, "7" => 7, "8" => 8, "9" => 9, "10" => 10,
"11" => 11, "12" => 12, "13" => 13, "14" => 14, "15" => 15,
"16" => 16, "17" => 17, "18" => 18, "19" => 19, "20" => 20,
"21" => 21, "22" => 22, "23" => 23, "24" => 24, "25" => 25,
"26" => 26, "27" => 27, "28" => 28, "29" => 29, "30" => 30,
"31" => 31,
# Built from the optional @Date::Language::English::Dsuf array ...
"1st" => 1, "2nd" => 2, "3rd" => 3, "4th" => 4, "5th" => 5,
"6th" => 6, "7th" => 7, "8th" => 8, "9th" => 9, "10th" => 10,
"11th" => 11, "12th" => 12, "13th" => 13, "14th" => 14, "15th" => 15,
"16th" => 16, "17th" => 17, "18th" => 18, "19th" => 19, "20th" => 20,
"21st" => 21, "22nd" => 22, "23rd" => 23, "24th" => 24, "25th" => 25,
"26th" => 26, "27th" => 27, "28th" => 28, "29th" => 29, "30th" => 30,
"31st" => 31,
# From Date::Manip::Lang::english::Language->{nth} arrays ...
'first' => -1, 'second' => -2, 'third' => -3,
'fourth' => -4, 'fifth' => -5, 'sixth' => -6,
'seventh' => -7, 'eighth' => -8, 'ninth' => -9,
'tenth' => -10, 'eleventh' => -11, 'twelfth' => -12,
'thirteenth' => -13, 'fourteenth' => -14, 'fifteenth' => -15,
'sixteenth' => -16, 'seventeenth' => -17, 'eighteenth' => -18,
'nineteenth' => -19, 'twentieth' => -20, 'twenty-first' => -21,
'twenty-second' => -22, 'twenty-third' => -23, 'twenty-fourth' => -24,
'twenty-fifth' => -25, 'twenty-sixth' => -26, 'twenty-seventh' => -27,
'twenty-eighth' => -28, 'twenty-ninth' => -29, 'thirtieth' => -30,
'thirty-first' => -31,
# From Date::Manip::Lang::english::Language->{nth} arrays ...
'one' => -1, 'two' => -2, 'three' => -3,
'four' => -4, 'five' => -5, 'six' => -6,
'seven' => -7, 'eight' => -8, 'nine' => -9,
'ten' => -10, 'eleven' => -11, 'twelve' => -12,
'thirteen' => -13, 'fourteen' => -14, 'fifteen' => -15,
'sixteen' => -16, 'seventeen' => -17, 'eighteen' => -18,
'nineteen' => -19, 'twenty' => -20, 'twenty-one' => -21,
'twenty-two' => -22, 'twenty-three' => -23, 'twenty-four' => -24,
'twenty-five' => -25, 'twenty-six' => -26, 'twenty-seven' => -27,
'twenty-eight' => -28, 'twenty-nine' => -29, 'thirty' => -30,
'thirty-one' => -31,
);
my $date_manip_installed_flag = keys %date_manip_installed_languages;
my $date_language_installed_flag = keys %date_language_installed_languages;
# Tells what to do about the negative values in the hashes ...
my $flip = $date_manip_installed_flag || (! $date_language_installed_flag);
$last_language_edit_flags{language} = "English";
$last_language_edit_flags{month_period} = 0;;
$last_language_edit_flags{dsuf_period} = 0;
$last_language_edit_flags{dow_period} = 0;;
foreach ( keys %Months ) {
next if ( $Months{$_} > 0 );
if ( $flip ) {
$Months{$_} = abs ($Months{$_});
} else {
delete $Months{$_};
}
}
foreach ( keys %Days ) {
next if ( $Days{$_} > 0 );
if ( $flip ) {
$Days{$_} = abs ($Days{$_});
} else {
delete $Days{$_};
}
}
}
# How many days per month ... (non-leap year)
# ---------------------> J F M A M J J A S O N D
my @days_in_months = ( 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
# Updated by: init_special_date_arrays() ...
# May be for a different language than the above hashes ...
my $prev_array_lang = "English";
my @gMoY = qw ( January February March April May June
July August September October November December );
( run in 0.939 second using v1.01-cache-2.11-cpan-39bf76dae61 )