These are just thoughts; it's a project I plan to be working on soon, but have yet to work through the date collision details. However my thought is "use a range of numbers". Figure out your increments, and store the start and end times, along with an array of numbers that represent the times, likely in 24-hour format. For example --  my @hours = (13, 13.25, 13.5, 13.75, 14, 14.25, 14.5, 14.75, 15). Store the array in the DB in some fashion – I admit nothing excellent comes to mind, as a (var)char would have to be parsed, and a cross-reference table might just be overkill. Update2: Of course, it should be possible to auto-generate the numbers in Perl, each time you make the query I talk about next...benchmarking would help tell which approach is best.

At any rate, in Perl, do a SQL query that grabs that array, and also queries for any events whose end time is after your start time, or who's start time is before your end time. Iterate each row from the table against the New Event's array of times, and use something to figure out the Intersection of the two sets -- maybe Array::Compare? The Perl Cookbook also has a solution for this. Whatever matches, is a collision you’ll need to deal with.

This is a very naive solution, so I hope others can improve on it, or offer a different, more refined algorithm for this process. I do hope it helps, though, and if I do the project in question, I'll try to remember to come back and report on it!

Update: Upon relection, there's a module to interface to Google Calendar; it can do a lot of the scheduling for you, although I doubt I'll be able to use it for mine. I did some early work, prior to this module's release, on interfacing with GCal, and I found it rough, but do-able -- and it's been improved, I'm told, since those early days quite a bit.

----Asim, known to some as Woodrow.


In reply to Re: (OT) designing a "per event, resource schedule" manager by Asim
in thread (OT) designing a "per event, resource schedule" manager by leocharre

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.