Add %EB russian date format

databind
vitalif 2010-07-04 17:34:36 +00:00 committed by Vitaliy Filippov
parent 0a990085d0
commit 55a7efee2b
2 changed files with 16 additions and 2 deletions

View File

@ -30,7 +30,7 @@ our @EXPORT_OK = qw(
file_get_contents dbi_hacks ar1el filemd5 mysql_quote updaterow_hashref updateall_hashref
insertall_arrayref insertall_hashref deleteall_hashref dumper_no_lf str2time callif urandom
normalize_url utf8on utf8off rfrom_to mysql2time mysqllocaltime resub requote
hashmrg litsplit strip_tagspace timestamp strlimit daemonize
hashmrg litsplit strip_tagspace timestamp strlimit daemonize estrftime
), @EXPORT;
our %EXPORT_TAGS = (all => [ @EXPORT_OK ]);
@ -610,6 +610,20 @@ sub timestamp
return $ts;
}
# strftime с поддержкой %EB (месяц в родительном падеже)
my @month_gen = qw/Января Февраля Марта Апреля Мая Июня Июля Августа Сентября Октября Ноября Декабря/;
sub estrftime
{
my $format = shift;
my $u;
my $m = $month_gen[$_[4]];
Encode::_utf8_on($m) if $u = Encode::is_utf8($format);
$format =~ s/\%EB/$m/gse;
my $r = POSIX::strftime($format, @_);
Encode::_utf8_on($r) if $u;
return $r;
}
sub date_init_russian
{
my $r = &$orig_DIRussian(@_);

View File

@ -803,7 +803,7 @@ sub function_strftime
my $self = shift;
my $e = $_[1];
$e = "($e).' '.($_[2])" if $_[2];
$e = "POSIX::strftime($_[0], localtime(timestamp($e)))";
$e = "VMX::Common::estrftime($_[0], localtime(timestamp($e)))";
$e = "utf8on($e)" if $self->{use_utf8};
return $e;
}