Results 1 to 4 of 4

Thread: Leap Year Dates

  1. #1

    Leap Year Dates

    Hello:

    I have some ideas for many scripts that I would like to develop, but I have an issue. How would one code a script, such as a billing system, so that it doesn't skip sending invoices on a leap-year? In other words, say someone signs up on February 29th on a leap year, then when the next year rolls around there is no February 29th until 3 years later. How would I be able to solve this problem? I know it seems like a small thing, but Im not sure how I would do it, or how OTHERS do it. I would have no problem just telling the script to check for the 29th and if its that, set their billing date for the 28th, but I dont know if other people do that, or what they do.

    Also, how would I go about making it so that my (PHP) script will display only X number of results per page, and color every other row a different color?

    Please give me some pointers. Thanks!
    Last edited by MyFocal; 10-28-2005 at 01:04 PM. Reason: Adding More

  2. #2
    For the 29th/leap year issue - I would put in some text at the time that a customer/user would see the date: "Today (Feb. 29) is a leap day, so we are giving you a free day by backdating your membership to Feb. 28th. You will not be billed extra for this day - enjoy!"

  3. #3
    Join Date
    Mar 2004
    Location
    Kingston, Canada
    Posts
    118
    Quote Originally Posted by MyFocal
    Hello:
    Also, how would I go about making it so that my (PHP) script will display only X number of results per page, and color every other row a different color?
    It depends on exactly how you are generating your table. A simple way to do it if you have data in an array and use a for loop might be:

    Code:
    $colour = false;
    
    for ($i = startValue ; $i < $endValue ; $i++){
      if ($colour){
        echo "<tr><td bgcolour=\"some colour here\">";
        $colour = false;
      } // end if
      else {
        echo "<tr><td bgcolour=\"some other colour here or remove the bgcolour\">";
        $colour = true;
      } // end else
    
        ....stuff....
    
      echo "</td></tr>";
    }// end for
    There is some pseudo code, its just meant as a starting point.
    My site: redclaw.ca

  4. #4
    Its not really an issue is it?

    At worst, you would have to have your script search for any orders as of 02/29 and update the date in the DB.

    Better yet, bill prorated to the 1st or 15th or whatever.

    You might be tempted to try your database's date functions to check and see what happens when you add 30 days to the 29th of Feb. With mysql, its no issue at all it will give the correct date.
    "The only difference between a poor person and a rich person is what they do in their spare time."
    "If youth is wasted on the young, then retirement is wasted on the old"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •