For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > July 2006 > add_delta_days: 30.06.2006 +1 Day = 01.07.2006?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author add_delta_days: 30.06.2006 +1 Day = 01.07.2006?
thomas.reiss@gmx.de

2006-07-30, 6:57 pm

Hi,

attention, Beginner!

I'm wondering about the calculation from Modul Date::Calc.

The Code:

sub ids_tomorrow() {
my($year,$month,$day) = Add_Delta_Days(((localtime)[5,4,3]),1);
$year=$year+1900;
printf("Id's, tommorow: %02d.%02d.%04d\n",$day,$month,$year);
}

give me (called on 30.06.2006) as Resoult the Date 01.07.2006?
It should be 31.06.2006.
What made i wrong?

"Date::Calc" version 5.4
Perl: Ver. 5.8.8

Thanx for Help
Thomas

Mark Clements

2006-07-30, 6:57 pm

thomas.reiss@gmx.de wrote:
> Hi,
>
> attention, Beginner!
>
> I'm wondering about the calculation from Modul Date::Calc.
>
> The Code:
>
> sub ids_tomorrow() {
> my($year,$month,$day) = Add_Delta_Days(((localtime)[5,4,3]),1);
> $year=$year+1900;
> printf("Id's, tommorow: %02d.%02d.%04d\n",$day,$month,$year);
> }
>
> give me (called on 30.06.2006) as Resoult the Date 01.07.2006?
> It should be 31.06.2006.
> What made i wrong?
>
> "Date::Calc" version 5.4
> Perl: Ver. 5.8.8
>


June only has 30 days.

Mark
thomas.reiss@gmx.de

2006-07-31, 7:56 am


Mark Clements schrieb:

> thomas.reiss@gmx.de wrote:
>
> June only has 30 days.
>
> Mark


Upps, sorry my mistake, i live at the wrong Month ;-)
The Skript was not called on 06/2006 but on 07/2006!
But Your hint was very usefull.

localtime returns the month beginning with 0 for January,
Add_Delta_Days await the January with 1 !

so i have to add 1 to $month.

Thank's for help
Thomas

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com