I need to use DateTime functionality and would like to know
if the particular functionality I need already exists on
CPAN.

I need to construct a series of time segments which do not
overlap but which do not need to be contiguous.  Each
segment is defined by a start date which is part of the
segment and by an end date which is the first moment in time
after the segment's conclusion.

Example:

    2013-01-01 00:00:00
    2013-02-01 00:00:00

    2013-03-01 00:00:00
    2013-04-01 00:00:00

    2013-04-01 00:00:00
    2013-04-15 00:00:00

The above would represent a series of 3 segments consisting,
in human speak, of January 2013, March 2013 and the first 14
days of April 2013.  The first two segments are not
contiguous; the second and third are.

I am permitted to create additional segments before, between
or after existing segments provided that they do not overlap
any existing segment.  I can therefore add any of the
following segments:

    2012-12-15 00:00:00
    2013-01-01 00:00:00

    2013-02-01 00:00:00
    2013-03-01 00:00:00

    2013-04-15 00:00:00
    2013-04-16 00:00:00

... but I am not permitted to add either of these segments:

    2013-02-15 00:00:00
    2013-03-15 00:00:00

    2013-04-01 00:00:00
    2013-04-08 00:00:00

This means that whether initially creating, or subsequently
updating the series, I must always confirm that a given
segment does not overlap an existing segment.

Once I have built an object representing a series, I need
one or more methods to determine whether a given point in
time:

* falls within a particular segment -- in which case that
segment is identified;

* falls before the first segment, which is then identified;

* falls between two segments, in which both of those are
identified; or

* falls after the last segment, which is then identified.

Can you tell me whether prior art exists for this?

Thank you very much.
Jim Keenan

Reply via email to