Feedback requested on alternate interface to Time::Period

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Let me know if this (Time::Period::Naive) is worth polishing and
uploading to CPAN.  My own comment: 'Simple' or 'Easy' might be better
alternatives to 'Naive'.

=head1 NAME

Time::Period::Naive - alternate interface to Time::Period, to deal
with certain time periods (ranges) more intuitively


  use Time::Period::Naive;
  inPeriodNaive($time, $alternate_period_syntax);


B<Time::Period::Naive> allows an alternate syntax for specifying
periods/ranges to B<Time::Period>.

Example: Time::Period::Naive allows you to use the following syntax:


instead of the equivalent Time::Period notation:

  wd hr min , wd hr min

Keep in mind that Time::Period::Naive syntax is extremely limited
compared to that of Time::Period, but it is good for specifying
contiguous time periods that occur weekly or daily.

The day of week (followed by the at sign) is optional, but if it is
absent, it must be absent on both sides of the dash.  You can use
either AM/PM notation, or 24-hour clock notation.  12:00AM is
considered the start of a day and is equivalent to 00:00 in 24-hr
clock time.  Multiple ranges can be separated by commas. AM/PM
indications are not case-sensitive, and you can also use 'a' or 'p'.

B<Warning>: if you pass an empty string or an undefined value to
inPeriodNaive() as its second argument, then inPeriodNaive() indicates
success (returns 1).  inPeriodNaive() behaves the same as inPeriod()
in this regard.

Likewise, the special (case-insensitive) token B<none>
causes automatic failure (0 is returned).

Whitespace is not significant in the time period specification
string; all space is stripped from the second argument before parsing.


=over 4


The range is considered to extend up to but not include the second
time specification, e.g. "12:00-12:01" would be equivalent to the
Time::Period syntax "hr min ", and I<not> "hr min ".


=head2 WHEN NOT TO USE Time::Period::Naive

Use B<Time::Period> instead of B<Time::Period::Naive> whenever you are
B<not> dealing with one or a small number of contiguous time intervals
that happen weekly or daily.

For instance, the example "Monday through Friday, 9am to 5pm" from the
Time::Period man page gets a little awkward:

  Mon@9:00am-Mon@5:00pm, Tue@9:00am-Tue@5:00pm, Wed@9:00am-Wed@5:00pm,
  Thu@9:00am-Thu@5:00pm, Fri@9:00am-Fri@5:00pm

compared to the elegant Time::Period syntax:

  wd hr


Re: Feedback requested on alternate interface to Time::Period

Quoted text here. Click to load it
Many modules have "extension" Lite so maybe Time::Period::Lite ?

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Site Timeline