> -----Original Message-----
> From: Chris Payne [mailto:[EMAIL PROTECTED]]
> Sent: 20 February 2003 01:52
> OK here is a final date question.  It's complex (Atleast to 
> me :-( but i'm totally stumped.  Here's what I need to do.  
> Say September is Summer and October is winter, now getting 
> the dates for each month is easy.
> Now, say in September each day is worth $50 but in October 
> each day of the month is worth $70.
> Now finally, say you choose 2 days in September and 2 in 
> October (And this is what stumps the living crap out of me - 
> pardon les francais :-) the system has to know "He chose 2 in 
> september so that's $100 in total, but hold on, wait a 
> minute, he chose 2 in october and these are worth $140 for 2 
> days) - so how can I get it to do that?  I know how to get it 
> to do the september, but finding that it ran into October and 
> that Octobers 2 days are worth more than septembers just 
> totally goes over my head :-(

Well, you must have a start date and an end date -- and you must be able to
work out in which season each one lies.  So check whether the start date is
in the same season as the end date -- if it is, all is hunky-dory; if not,
then you have to work out how many days are in each season, calculate the
subtotals for each group of days, and then add them back together to get a
grand total.

I would commend to you the construction mktime(12, 0, 0, 0, $month+1, $year)
for finding the timestamp for midday of the last day of $month in $year --
works even when $month represents December!  (Note: you need to watch out
for daylight savings timeshifts if appropriate; you may prefer to do all
your day-offset calculations using an appropriate time of day with
gmmktime() so as to eliminate DST shift vagaries entirely!)



Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to