Forum Moderators: coopster & phranque

Message Too Old, No Replies

Issue with time logic

need to find a perl time algorithm for a problem

         

Shadi

7:48 am on Aug 28, 2003 (gmt 0)

10+ Year Member



am not sure if am allowed to post such a question on here but am having a slight logic problem...

i need my script to provide me with a specific date ($mydate). now here are the requirements:

the script runs daily. the date that the script needs to calculate is always the next monday e.g. if the script ran today (28/8/2003) it will use the date 1/9/2003 for this monday coming. now it needs to do every day apart from sunday on a sunday it needs to get the next monday. e.g. if i ran it this sunday (31/8/2003) it will need the date (8/9/2003) you follow me? :)

now am using perl and i for some reason can't get my heard round a simple efficiant way to do this, any help would be appreciated!

thanks

netcommr

8:07 am on Aug 28, 2003 (gmt 0)

10+ Year Member



# 1 == monday
until ($my_day_of_week == 1) {
$current_time += 86400; # 86400 = sec./day
$my_day_of_week = -1 if $my_day_of_week > 6;
$my_day_of_week += 1;

# somehow check for runaway routine here

}

$x = &display_current_time($current_time);

sort of ...

I know there is a better way than this, this is sloppy, more help?...