Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've had this idea since I was still programming in GW Basic ;-) though, back then, I took option #3 and that was it. Looking back at it, and also some of the other responses, this would be my current solution.</p> <p><strong>table structure</strong></p> <pre><code>start (datetime) stop (datetime, nullable) interval_unit ([hour, day, week, month, year?]) interval_every (1 = every &lt;unit&gt;, 2 every two &lt;units&gt;, etc.) type ([positive (default), negative]) - will explain later </code></pre> <p>Optional fields:</p> <pre><code>title duration </code></pre> <p>The <code>type</code> field determines how the event is treated:</p> <ol> <li>positive; normal treatment, it shows up in the calendar</li> <li>negative; this event cancels out another (e.g. every Monday but not on the 14th)</li> </ol> <p><strong>helper query</strong></p> <p>This query will narrow down the events to show:</p> <pre><code>SELECT * FROM `events` WHERE `start` &gt;= :start AND (`stop` IS NULL OR `stop` &lt; :stop) </code></pre> <p>Assuming you query a range by dates alone (no time component), the the value of <code>:stop</code> should be one day ahead of your range.</p> <p>Now for the various events you wish to handle.</p> <p><strong>single event</strong></p> <pre><code>start = '2012-06-15 09:00:00' stop = '2012-06-15 09:00:00' type = 'positive' </code></pre> <p><em>Event occurs once on 2012-06-15 at 9am</em></p> <p><strong>bounded repeating event</strong></p> <pre><code>start = '2012-06-15 05:00:00' interval_unit = 'day' interval_every = 1 stop = '2012-06-22 05:00:00' type = 'positive' </code></pre> <p><em>Events occur every day at 5am, starting on 2012-06-15; last event is on the 22nd</em></p> <p><strong>unbounded repeating event</strong></p> <pre><code>start = '2012-06-15 13:00:00' interval_unit = 'week' interval_every = 2 stop = null type = 'positive' </code></pre> <p><em>Events occur every two weeks at 1pm, starting on 2012-06-15</em></p> <p><strong>repeating event with exceptions</strong></p> <pre><code>start = '2012-06-15 16:00:00' interval_unit = 'week' interval_every = 1 type = 'positive' stop = null start = '2012-06-22 16:00:00' type = 'negative' stop = '2012-06-22 16:00:00' </code></pre> <p><em>Events occur every week at 4pm, starting on 2012-06-22; but not on the 22nd</em></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload