App-SpreadRevolutionaryDate
view release on metacpan or search on metacpan
lib/App/SpreadRevolutionaryDate/MsgMaker/RevolutionaryDate.pm view on Meta::CPAN
#
# This file is part of App-SpreadRevolutionaryDate
#
# This software is Copyright (c) 2019-2026 by Gérald Sédrati.
#
# This is free software, licensed under:
#
# The GNU General Public License, Version 3, June 2007
#
use 5.014;
use utf8;
package App::SpreadRevolutionaryDate::MsgMaker::RevolutionaryDate;
$App::SpreadRevolutionaryDate::MsgMaker::RevolutionaryDate::VERSION = '0.54';
# ABSTRACT: MsgMaker class for L<App::SpreadRevolutionaryDate> to build message with revolutionary date
use Moose;
with 'App::SpreadRevolutionaryDate::MsgMaker';
use App::SpreadRevolutionaryDate::MsgMaker::RevolutionaryDate::Calendar;
use Locale::TextDomain 'App-SpreadRevolutionaryDate';
use namespace::autoclean;
has '+locale' => (
default => 'fr',
);
has 'acab' => (
is => 'ro',
isa => 'Bool',
required => 1,
default => 0,
);
has 'wikipedia_link' => (
is => 'ro',
isa => 'Bool',
required => 1,
default => 1,
);
around BUILDARGS => sub {
my ($orig, $class, %args) = @_;
$args{locale} = 'fr'
unless $args{locale}
&& grep { $args{locale} eq $_ } ('en', 'it', 'es');
return $class->$orig(%args);
};
sub compute {
my $self = shift;
# As of App::SpreadRevolutionaryDate 0.11
# locale is limited to 'fr', 'en', 'it' or 'es', defaults to 'fr'
# forced to 'fr' for any other value
my $revolutionary = $self->acab ?
App::SpreadRevolutionaryDate::MsgMaker::RevolutionaryDate::Calendar->now->set(hour => 1, minute => 31, second => 20, locale => $self->locale)
: App::SpreadRevolutionaryDate::MsgMaker::RevolutionaryDate::Calendar->now->set(locale => $self->locale);
my $feast_long = $revolutionary->feast_long;
my $today = DateTime->today;
if ($self->special_birthday_day && $self->special_birthday_month && $self->special_birthday_name && $today->day == $self->special_birthday_day && $today->month == $self->special_birthday_month) {
$feast_long = $revolutionary->locale->prefixes->[$self->special_birthday_prefix] . $self->special_birthday_name . $revolutionary->locale->suffix;
}
my $msg = __x("We are {day_name}, {day} {month} of Revolution year {roman_year} ({year}), {feast_long}, it is {time}!",
day_name => $revolutionary->day_name,
day => $revolutionary->day,
month => $revolutionary->month_name,
roman_year => $revolutionary->strftime("%EY"),
year => $revolutionary->year,
feast_long => $feast_long,
time => $revolutionary->hms,
);
if ($self->special_birthday_day && $self->special_birthday_month && $self->special_birthday_name && $today->day == $self->special_birthday_day && $today->month == $self->special_birthday_month && $self->special_birthday_url) {
$msg .= ' ' . $self->special_birthday_url;
} elsif ($self->wikipedia_link) {
use URI::Escape;
my $entry = $revolutionary->locale->wikipedia_redirect($revolutionary->month, $revolutionary->feast_short);
( run in 1.136 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )