App-JobLog
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/JobLog/Log/Format.pm view on Meta::CPAN
package App::JobLog::Log::Format;
$App::JobLog::Log::Format::VERSION = '1.042';
# ABSTRACT: pretty printer for log
use Exporter 'import';
our @EXPORT_OK = qw(
display
duration
single_interval
summary
wrap
);
use Modern::Perl;
use App::JobLog::Config qw(
day_length
is_workday
precision
);
use App::JobLog::Log::Synopsis qw(collect :merge);
use Text::WrapI18N qw();
use App::JobLog::TimeGrammar qw(parse);
use constant TAG_COLUMN_LIMIT => 10;
use constant MARGIN => 5;
# minimum width of description column
use constant MIN_WIDTH => 20;
use constant DURATION_FORMAT => '%0.' . precision . 'f';
sub summary {
my ( $phrase, $test, $hidden, $do_notes ) = @_;
# we skip flex days if the events are at all filtered
my $skip_flex = !$do_notes && ( $test || 0 );
$test //= sub { $_[0] };
my ( $start, $end ) = parse $phrase;
my $show_year = $start->year < $end->year;
unless ($skip_flex) {
# if we are chopping off any of the first and last days we ignore flex time
$skip_flex = 1
unless $do_notes || _break_of_dawn($start) && _witching_hour($end);
}
my $method = $do_notes ? 'find_notes' : 'find_events';
my $events = App::JobLog::Log->new->$method( $start, $end );
my @days = @{ _days( $start, $end, $skip_flex, $do_notes ) };
my @periods =
$hidden->{vacation} ? () : App::JobLog::Vacation->new->periods;
# drop the vacation days that can't be relevant
unless ( $hidden->{vacation} ) {
my $e =
App::JobLog::Log::Event->new(
App::JobLog::Log::Line->new( time => $start ) );
$e->end = $end;
for ( my $i = 0 ; $i < @periods ; $i++ ) {
my $p = $periods[$i];
if ( $skip_flex && $p->flex || !$p->conflicts($e) ) {
splice @periods, $i, 1;
$i--;
}
}
}
# collect events into days
my @gathered;
for my $big_e (@$events) {
for my $e ( $big_e->split_days ) {
if ( $e = $test->($e) ) {
push @gathered, shift @days
while @days && $days[0]->end < $e->start;
for my $d (@days) {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.669 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )