I'm not sure if I correctly understand the problem, but it seems that given the epoch time of a given month you want to get the epoch time for the next month. Right?
Why not try this... # UNTESTED! $TestingTime = nextMonth($TestingTime); sub nextMonth { my $time = shift; # get date info for that time, increment month only. my @date = localtime($time); $date[4]++; # check for month out of bounds. if ( $date[4] == 12 ) { $date[5]++; $date[4] = 0; } # return new time return timelocal(@date); } Rob -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 27, 2001 2:41 AM To: [EMAIL PROTECTED] Subject: sub to jump to begining of month Hi all, as part of my program i want to jump from 00:00:00 on the first of any given month to 00:00:00 on the first of the next month. i wrote a subroutine to calculate this. the relevent code looks like this ==================================================== my ($sec,$min,Hour,$mday,$mon,$year)=localtime(time); #get first of this month my $StopTime=timelocal(0,0,0,1,$mon,$year); my $TimetoFix=86400*7*12; #approx. 3 months back #get first day of startmonth my ($ssec,$smin,$shour,$sday,$smon,$syear)=localtime($TesmpStartTime); my $TestingTime=timelocal(0,0,0,1,$smon,$syear); while ($TestingTime < $StopTime) { #irrelevent code cut ... #jump to begining of next month my $days=Days_In_Month($dates[4]); my $jump= ($days * 86400); $TestingTime+=$jump; } sub Days_In_Month #this sub returns how many days are in each month { my ($mon) = @_; if ($mon == '0') { return 31; } if ($mon == '1') { return 28; } if ($mon == '2') { return 31; } if ($mon == '3') { return 30; } if ($mon == '4') { return 31; } if ($mon == '5') { return 30; } if ($mon == '6') { return 31; } if ($mon == '7') { return 31; } if ($mon == '8') { return 30; } if ($mon == '9') { return 31; } if ($mon == '10') { return 30; } if ($mon == '11') { return 31; } } ==================================================== the program starts off correctly at $TestingTime = 999291600 (Sep 1 00:00:00 2001) but when i try to jump to the 1001887200 (Oct 1 00:00:00 2001). $TestingTime= 1001883600 (Sep 30 23:00:00 2001) can someone please show me where i went wrong? -- - josh N8MSO 20A8 2FC6 9099 D215 78F4 D005 B9F3 21C4 300C C25E ~. .~ Tk Open Systems =}------------------------------------------------ooO--U--Ooo------------{= - [EMAIL PROTECTED] - tel: +972.58.520.636, http://www.tkos.co.il -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]