1
我正试图返回今天的生日。这就是我现在所拥有的,这是有效的,但我需要抓住月份和日子来输入声明。我想也许我可以从当地时间抓住他们,但那并没有奏效。任何建议,将不胜感激。DBIx :: Class和搜索
sub author_birth {
my ($self) = @_;
my ($day,$month) = (localtime())[3..4];
my $author_result = $self->search_like(
{
birth => '%03-20'
},
{
select => [
'id',
'complete_name',
],
#result_class => 'DBIx::Class::ResultClass::HashRefInflator'
}
);
my @author_ids =();
while (my $row = $author_result->next) {
push @author_ids, $row->id;
}
return $self->get_author_info_by_id(\@author_ids);
}
它不适用于'$ day'和'$ month',因为它们不包含数据库中日期包含的前导零。最好的解决方案(你似乎已经制定出来)是使用Time :: Piece。 – 2013-03-20 09:59:42
感谢您的解释,直到昨天我才意识到Time :: Piece。干杯。 – 2013-03-20 16:09:57