Feedback requested on alternate interface to Time::Period
am 08.03.2007 21:19:03 von lapidariusLet 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
=head1 SYNOPSIS
use Time::Period::Naive;
inPeriodNaive($time, $alternate_period_syntax);
=head1 DESCRIPTION
B
periods/ranges to B
Example: Time::Period::Naive allows you to use the following syntax:
Sat@11:55pm-Sun@12:05am
instead of the equivalent Time::Period notation:
wd {sat} hr {11pm} min {55-59}, wd {sun} hr {12am} min {0-4}
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
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
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.
=head2 IMPORTANT DIFFERENCES FROM Time::Period
=over 4
=item
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 {12} min {0}", and I
=back
=head2 WHEN NOT TO USE Time::Period::Naive
Use B
B
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 {Mon-Fri} hr {9am-4pm}
=cut