App-JobLog

 view release on metacpan or  search on metacpan

lib/App/JobLog/Vacation/Period.pm  view on Meta::CPAN


        # cloning here should be duplicated work, but better safe than sorry
        my $cloned = 0;
        if (   $self->annual
            || $self->monthly && $self->start->year != $start->year )
        {
            $self   = $self->clone;
            $cloned = 1;
            my $delta = $start->year - $self->start->year;
            $self->start->add( years => $delta );
            $self->end->add( years => $delta );
        }
        if ( $self->monthly && $self->start->month != $start->month ) {
            $self = $self->clone unless $cloned;
            my $delta = $start->month - $self->start->month;
            $self->start->add( months => $delta );
            $self->end->add( months => $delta );
        }
    }
    return $self->SUPER::overlap( $start, $end );
}

# tag part of summary
sub _tags {
    my ($self) = @_;
    return join ', ', @{ $self->tags };
}

# description part of summary
sub _description {
    my ($self) = @_;
    return join '; ', @{ $self->description };
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::JobLog::Vacation::Period - extension of L<App::JobLog::Log::Event> to handle special properties of vacation periods

=head1 VERSION

version 1.042

=head1 DESCRIPTION

C<App::JobLog::Vacation::Period> extends L<App::JobLog::Log::Event> to add repeating events and flexible
time events and to allow a different serialization convention such that events take a single line in their
file.

=head1 METHODS

=head2 flex

Whether time in a period is "flexible". Flexible time off shrinks or expands to provide
enough work hours to complete the day it occurs in.

=head2 fixed

Whether time in a period is "fixed". Fixed periods have a definite start and end time. Regular
vacation time is just a fixed period of virtual work in the day but at nor particular time 
and flexible vacation time is just as much time as you need to fill out your work day, again
without any particular start or end.

=head2 annual

Whether this period repeats annually on a particular range of days in particular months. 

=head2 annual

Whether this period repeats monthly on a particular range of days.

=head2 repeats

Whether this vacation repeats periodically.

=head2 description

The description of the vacation period. Lvalue method.

=head2 clone

Overrides L<App::JobLog::Log::Event>'s C<clone> method to add cloning of special vacation
properties.

=head2 cmp

Overrides L<App::JobLog::Log::Event>'s C<cmp> method so that repeating vacations sort
above non-repeating ones.

=head2 parse

Class method parsing line in F<vacation> into a vacation object.

=head2 to_string

Serializes period into something printable in the vacation file.

=head2 conflicts

Determines whether two events overlap in time.

=head2 parts

Converts period into list of displayable parts: time, properties, tags, description.

=head2 single_day

Whether this period concerns a single day or a longer span of time.

=head2 overlap

Adjust start and end times for annual or monthly periods then delegates to
superclass method in L<App::JobLog::Log::Event>.



( run in 0.393 second using v1.01-cache-2.11-cpan-5623c5533a1 )