[nycphp-talk] Faced with a headache :D
Joseph Crawford
codebowl at gmail.com
Mon Mar 20 17:54:08 EST 2006
Hey guys,
I have a database of vendors, each have different days and times they are
open from.
now what i need to do is this
check to see if the vendor is open at the current time, if not i need to
check the next day, then the next, etc..
I have some simple code that is not in working form, that is this
$time = '';
$day = date('w');
$days = 1;
// getLeadTime() returns a time in minutes,
converting to seconds so we can add it to the timestamp.
$leadTime = 60 * $location->getLeadTime();
$i = $day;
while($i <= 6) {
$curday = $day + $i;
if($curday == 7) {
$i = 0;
$curday = 6;
}
// getOpenTime() returns a string such as
10:00:00 or 23:30:00
$timeStr = $location->getOpenTime($curday);
// if $timStr is = 00:00:00 then it needs to
continue on to the next loop
if($timeStr == '00:00:00') {
$i++;
$days++;
continue;
}
}
// now we need to get the timestamp, this is
where the strtotime converts the string from getOpenTime to a timestamp and
we add the leadTime
$vendorOpenTime =
strtotime($location->getOpenTime($day + $days)) + $leadTime;
Now the above code works fine if they are closed on Monday and not open
again until Thursday, the trouble lies in being closed Sat and Sun, it
doesnt flip over to Monday. it just says get it delivered today, even if
they are closed the current day.
Anyone who can help me with this i would appreciate it, i wouldnt even mind
paying someone to help me nail this logic :D I have spent pretty much about
5 hours on this and i think i just need another brain to pick at it :)
Thanks,
--
Joseph Crawford Jr.
Zend Certified Engineer
Codebowl Solutions, Inc.
http://www.codebowl.com/
1-802-671-2021
codebowl at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060320/c85ea7a8/attachment.html>
More information about the talk
mailing list