Scripting Fun :: Automatic Next Meeting Date Calculation

OK. I have finally taken the time to hack together a block for automatically stating the Next PHP Meeting date. What I needed was a way to get the third Saturday of the current month unless it has already past. Then it would get the third Saturday of next month.

If you want to have some fun with a nice academic exercise, read the article and start hacking!

The “algorithm” I hacked together was:
[code]
[/code]

Now make me proud and post your improvements.

Happy Hacking!!

7 thoughts on “Scripting Fun :: Automatic Next Meeting Date Calculation

  1. Re: Scripting Fun :: Automatic Next Meeting Date Calculation
    What? No Zend Framework? After the discussion at the meeting last time, or was it the time before? I figured this would be showing that off.
    • Re: Scripting Fun :: Automatic Next Meeting Date Calculation
      *cough*

      Er…yeah. I’m using a xoops custom php block and wanted to keep it to just pure php. Any takers on using ZF for fun?

    • Re: Scripting Fun :: Automatic Next Meeting Date Calculation
      I shouldn’t have to worry about any carry over, because mktime converts my overflows (month 13 for example) into the appropriate time.

      What I do find odd, is that both September and December this year start on Saturday the 1st. Now, that’s no so strange, but what is is that my little algorithm works on my Unix hosted website, but in XAMPP in windows it’s off a weekend.

      It the month starts on a Saturday, I need to subtract a second from midnight. Naturally, mktime returns the last second of the last day of the previous month…and then the calculation is right.

      $this_month_start = mktime(0,0,-1,$t[‘mon’],1,$t[‘year’]);

      errr…maybe it’s just to late in the evening to be playing around. 🙂

      • Re: Scripting Fun :: Automatic Next Meeting Date Calculation
        November is off a day (shows the 3rd Sat as 11/16 rather than 11/17).

        strtotime() is using [url=http://www.gnu.org/software/tar/manual/html_node/tar_119.html]relative time[/url]. Line 6 of the above link says: [quote]When a relative item causes the resulting date to cross a boundary where the clocks were adjusted, typically for daylight saving time, the resulting date and time are adjusted accordingly.[/quote]
        Yet, the last line says: [quote]Also, take care when manipulating dates around clock changes such as daylight saving leaps. In a few cases these have added or subtracted as much as 24 hours from the clock, so it is often wise to adopt universal time by setting the TZ environment variable to ‘UTC0’ before embarking on calendrical calculations.[/quote]
        The date error looks like it might have something to do with Daylight Saving Time ending in November (new 2007 DST rules).

        • Re: Scripting Fun :: Automatic Next Meeting Date Calculation
          Thanks Eric. I’ve fixed it this month with a single line that guarantees success:

          $event_date = strtotime(“2007-11-17 14:30:00”);

          I’m a little nervous of what setting the TZ environment and what it would do to Xoops. 😉

          Besides–this fix conformes to my “just barely enough” attitude with kcpug.org maintenance.

Leave a Reply

Your email address will not be published. Required fields are marked *