Feedback requested on alternate interface to Time::Period
- From: "lapidarius" <murphy2@xxxxxxxxxxxxx>
- Date: 8 Mar 2007 12:19:03 -0800
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
=head1 SYNOPSIS
use Time::Period::Naive;
inPeriodNaive($time, $alternate_period_syntax);
=head1 DESCRIPTION
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:
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<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.
=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<not> "hr {12} min {0-1}".
=back
=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 {Mon-Fri} hr {9am-4pm}
=cut
.
- Follow-Ups:
- Re: Feedback requested on alternate interface to Time::Period
- From: Petr Vileta
- Re: Feedback requested on alternate interface to Time::Period
- Prev by Date: problems with Charts and "Perl_sv_2iv_flags"
- Next by Date: Re: Feedback requested on alternate interface to Time::Period
- Previous by thread: problems with Charts and "Perl_sv_2iv_flags"
- Next by thread: Re: Feedback requested on alternate interface to Time::Period
- Index(es):