S
soup_or_power
Is there any advantage in using Date::Manip API instead of localtime?
Here is some sample code I'm working on. Thanks!
my $d1=DateCalc("today", "+ 0 days");
my $sv_mon=0, $sv_yr=0;
for (my $i=0; $i<14;$i++) {
my $d=ParseDate($d1);
my $yr=substr($d,0,4);
my $mon=substr($d,4,2);
my $mday=substr($d,6,2);
push @freq_mday, qq{<OPTION value="$mday"> $mday </OPTION>};
push @freq_mon, qq{<OPTION value="$mon"> $mon </OPTION>} if ($mon
!= $sv_mon);
push @freq_year, qq{<OPTION value="$yr"> $yr </OPTION>} if ($yr
!= $sv_yr);
$d1=DateCalc($d1,"+ 1 days");
$sv_mon=$mon;
$sv_yr=$yr;
}
same thing with localtime:
my $day_ref = [];
my $day = 0;
foreach my $day ( 0 .. 14 ) {
my ( $ss, $mi, $hh, $dd, $mm, $yy ) = localtime( time() + ( $day * 24
* 3600 ) );
$yy += 1900;
$mm += 1;
push @$day_ref, [ "$yy/$mm/$dd", "$yy/$mm/$dd" ];
}
Here is some sample code I'm working on. Thanks!
my $d1=DateCalc("today", "+ 0 days");
my $sv_mon=0, $sv_yr=0;
for (my $i=0; $i<14;$i++) {
my $d=ParseDate($d1);
my $yr=substr($d,0,4);
my $mon=substr($d,4,2);
my $mday=substr($d,6,2);
push @freq_mday, qq{<OPTION value="$mday"> $mday </OPTION>};
push @freq_mon, qq{<OPTION value="$mon"> $mon </OPTION>} if ($mon
!= $sv_mon);
push @freq_year, qq{<OPTION value="$yr"> $yr </OPTION>} if ($yr
!= $sv_yr);
$d1=DateCalc($d1,"+ 1 days");
$sv_mon=$mon;
$sv_yr=$yr;
}
same thing with localtime:
my $day_ref = [];
my $day = 0;
foreach my $day ( 0 .. 14 ) {
my ( $ss, $mi, $hh, $dd, $mm, $yy ) = localtime( time() + ( $day * 24
* 3600 ) );
$yy += 1900;
$mm += 1;
push @$day_ref, [ "$yy/$mm/$dd", "$yy/$mm/$dd" ];
}