Hi,
I was search for a way to get the unix time for the next couple of days
at 05:00:00 (a task of countless hours for me)
I found a easy way now to do so:
my $date = new Date::Manip::Date;
my $delta = $date->new_delta();
$date->parse("Today 05:00:00");
my $err = $delta->parse("1 day later");
$date = $date->calc($delta);
my $timestamp = $date->printf('%s');
But before i was trying it with $date->set() instead of the $delta approach:
my $date = new Date::Manip::Date;
my ($cur_year, $cur_month, $cur_day) = ParseDate('now') =~
m/(....)(..)(..)/;
$date->parse('now');
$date->set('time',['05','00','00']);
$cur_day = $cur_day+2; #$cur_day is 10 / 12
$date->set("y",$cur_day); #changes year
$date->set("m",$cur_day); #changes month
$date->set("d",$cur_day); #changes hour
$date->set("h",$cur_day); #changes minute
$date->set("mn",$cur_day); #changes secounds
$date->set("s",$cur_day); #changes nothing
print STDERR $date->printf('%s %c')."\n";
print STDERR $cur_day."\n";
output: Mon Dec 10 12:12:12 0012
cheers,
stefan
On 2010-11-10 15:01, Sullivan Beck via RT wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=62894>
>
> Could you please include more of the code that fails. You've only
> provided me with two lines:
>
> $cur_day = $cur_day+1;
> $date->set("d",$cur_day);
>
> but that doesn't tell me what $cur_day or $date were set to before, and
> you say that it only works with 'y' and 'm', but I'm not sure how you
> determine that.
>
> Could you provide a more complete example showing what $cur_day and
> $date were, and the results you obtained that demonstrate the bug?
>
> Thanks
>
>