Time::Piece で年月から epoch time をえる
use Time::Piece;
sub epoch\_from\_ym {
my $ym = shift;
$ym =~ /\\A\[0-9\]{4}-\[0-9\]{2}\\z/ or die "Invalid ym: $ym";
my $first = Time::Piece::localtime()->strptime($stuff, '%Y-%m');
my $last = Time::Piece::localtime()->strptime($stuff . '-' . $first->month\_last\_day . ' 23:59:59', '%Y-%m-%d %H:%M:%S');
return ($first->epoch, $last->epoch);
}
Published: 2013-05-28(Tue) 05:17