App-JobLog
view release on metacpan or search on metacpan
lib/App/JobLog/Command/summary.pm view on Meta::CPAN
return $test;
}
# look for regular expressions with side effects
sub _re_test {
carp 'regex ' . $_[0] . '" appears to contain executable code'
if $_[0] =~ /\(\?{1,2}{/;
}
# parse time expressions
our ( $b1, $b2 );
my $time_re = qr/
^ \s*+ (?&start) (?&end) \s*+ $
(?(DEFINE)
(?<start> (?&ba) | (?&time) )
(?<ba> (?:(?&before)|(?&after)) \s*+)
(?<before> (?: b(?:e(?:f(?:o(?:r(?:e)?)?)?)?)? | < ) (?{$b1 = 'before'}))
(?<after> (?: a(?:f(?:t(?:e(?:r)?)?)?)? | > ) (?{$b1 = 'after'}))
(?<time> (.*?) \s*+ - \s*+ (?{$b1 = $^N}))
(?<end> (\S.*) (?{$b2 = $^N}))
)
/xi;
sub _parse_time {
my ($time) = @_;
local ( $b1, $b2 );
return unless $time;
if ( $time =~ $time_re ) {
my ( $t1, $t2 );
for ($b1) {
when ('before') {
$t1 = {
hour => 0,
minute => 0,
second => 0
};
$t2 = { daytime $b2 };
}
when ('after') {
$t1 = { daytime $b2 };
$t2 = {
hour => 23,
minute => 59,
second => 59
};
}
default {
$t1 = { daytime $b1 };
$t2 = { daytime $b2 };
}
}
if ( $t2->{hour} < $t1->{hour}
|| $t2->{minute} < $t1->{minute}
|| $t2->{second} < $t1->{second} )
{
if ( $t2->{suffix} && $t2->{suffix} eq 'x' ) {
$t2->{hour} += 12;
}
else {
carp '"' . $time
. '" invalid time expression: endpoints out of order';
}
}
delete $t1->{suffix}, delete $t2->{suffix};
return { start => $t1, end => $t2 };
}
}
sub usage_desc { '%c ' . __PACKAGE__->name . ' %o [<date or date range>]' }
sub abstract {
'list tasks with certain properties in a particular time range';
}
sub full_description {
<<END
List events or notes with certain properties in a particular time range. Only the notes or
portions of events falling within the range will be listed.
Events and notes may be filtered in numerous ways: by tag, time of day, or terms used in descriptions.
If tags to match are provided, only those items that contain at least one such tag will be shown. If
tags not to match are provided, only those items that contain none of these tags will be shown.
If you provide description filters to match or avoid, these will be interpreted as regexes. Try 'perldoc perlre'
for more details, or perhaps 'perldoc perlretut' (these will only work if you have the Perl documentation
installed on your machine). If you don't want to worry about regular expressions, simple strings will work.
Prefix your expression with '(?i)' to turn off case sensitivity. And don't enclose regexes in slashes or any other
sort of delimiter. Use 'ab', not '/ab/' or 'm!ab!', etc. Finally, you may need to enclose your regexes in quotes
to prevent the shell from trying to interpret them.
Time subranges may be of the form '11-12pm', '1am-12:30:15', 'before 2', 'after 6:12pm', etc. Either 'before'
or 'after' (or some prefix of these such as 'bef' or 'aft') may be followed by a time or you may use two time
expressions separated by a dash. The code will attempt to infer the precise time of ambiguous time expressions,
but it's best to be explicit. Case is ignored. Whitespace is optional in the expected places.
Note that any filtering of events specifying particular times for the start and end of the period in question,
e.g., "yesterday at 8:00 am until today", will cause all flex time vacation to be ignored. This is because, given
the flexible nature of this vacation, it is unclear how much should be accounted for when filtering events. Since
notes are not "on the clock", no consideration of vacation periods is used in filtering them.
@{[__PACKAGE__->name]} provides many ways to consolidate events and notes. These are the "merge" options
By default items are grouped into days and within days into subgroups of adjacent items with the same tags.
All the merge options that require adjacency will also group by days but not vice versa.
END
}
sub options {
return (
[
"Use '@{[prog_name]} help "
. __PACKAGE__->name
. '\' to see full details.'
],
[],
[
'date|d=s',
'provide the time expression as an option instead of an argument'
],
[ 'notes|n', 'show notes instead of events' ],
[
'tag|t=s@',
( run in 1.268 second using v1.01-cache-2.11-cpan-63c85eba8c4 )