格式化日期:: Manip的Delta到天 [英] Formatting Date::Manip's Delta to days
本文介绍了格式化日期:: Manip的Delta到天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个例程,
我想保存这个增量来计算从到之间的每一天之间的日子
I有二维数组,我只需要工作日。
I want to save that delta to count the days between all to and from days in the from-to pairs I have in the 2 dimensional array, I just need the workdays.
说出
$date_from = 2012-02-09;
$date_to = 2012-02-13;
$delta_string = 4
sub calc_usage {
use Date::Manip::Date;
my $date_from;
my $date_to;
my $delta;
my $i;
for $i (0 .. $#DATE_HOLDER) {
$date_from = new Date::Manip::Date;
$date_to = new Date::Manip::Date;
$date_from->parse($DATE_HOLDER[$i][0]);
$date_to->parse($DATE_HOLDER[$i][1]);
$delta = $date_from->calc($date_to, "business");
}
}
推荐答案
要检索增量值,您必须使用以下内容:
To retrieve the delta values, you have to use the folllowing:
my @val = $delta->value();
其中包含7个元素的数组:
wich gives an array of 7 elements where:
$val[0] holds years
$val[1] holds months
$val[2] holds weeks
$val[3] holds days
$val[4] holds hours
$val[5] holds minutes
$val[6] holds seconds
您还可以在标量环境中使用它:
you can also use it in scalar context:
my $val = $delta->value();
w给出一个具有相同7个元素冒号分隔符的字符串:
wich gives a string with the same 7 elements colon separated:
years:months:weeks:days:hours:minutes:seconds
这篇关于格式化日期:: Manip的Delta到天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文