On Thu, 2 Oct 2003, RIck Measham wrote:

> $working_hours = new DateTime::Business::Week(
>         days  => [1 .. 5],
>         start => {hour => 9,  minute => 0},
>         end   => {hour => 17, minute => 30}
> );
>
> and, for those with more complex weeks:
>
> $working_hours = new DateTime::Business::Week(
>         {
>                 days  => [3 .. 5],
>                 start => {hour => 9,  minute => 0},
>                 end   => {hour => 17, minute => 30}
>         },
>         {
>                 days  => 6,
>                 start => {hour => 9,  minute => 0},
>                 end   => {hour => 17, minute => 00}
>         },
>         {
>                 days  => 7,
>                 start => {hour => 10,  minute => 30},
>                 end   => {hour => 16, minute => 30}
>         },
> );

This all looks reasonable.

> Basically Business::Week->new would return an infinite spanset for all
> working hours.

Actually, it should probably be something that _contains_ a span set.

> It could then be extended to allow for spans so we can include historical
> data:
>
> $working_hours->history(
>         span => $span,
>         week => $business_week
> );
>
> And such things as a finite span:
>
> $working_hours->set_start($dt1); # start of employment
> $working_hours->set_end($dt2);   # sacked!

In this case I think we might want to create a new object, something like:

 my $finite_working_hours =
     $working_hours->finite_chunk( start => $dt1, end => $dt2 );

> Then we could create other spansets for employee related information
>
> $working_hours->public_holiday( $recurrence ); # or $span or $spanset

I see us needing a couple things:

- Recording the fact that certain days are special non-work days.  This
includes both public holidays, company holidays, one shot things like
"fumigating the building", etc.  We not only want to record when these
are, but their names ("Christmas", "Company Founder's B-Day", "Fumigation
Day", etc.) and possibly other arbitrary data associated with them.

- Partial work days, which could again be a recurrence or a one-shot deal.
These need a name and a start/end time of day.

> $working_hours->annual_leave( $span ); # or $spanset
> $working_hours->sick_leave( $span ); # or $spanset

This seems like it belongs in a different module.

> Then we can set a project for a particular span:
>
> $working_hours->project(
>         name => 'Project X',
>         span => $span, # or $spanset
> );
> If given a 'name' this method returns spanset for that project.

ditto

> Now we can get a complete record of activity:
>
> print $working_hours->activity( $datetime );
> # Annual Leave
> print $working_hours->activity_span( $datetime )->min->ymd;
> # 2003-08-12
> print $working_hours->activity_span( $datetime )->max->ymd;
> # 2003-08-19

ditto again.

> And we need a quick boolean test to see if the person was actually at work
> print "Absent" unless $working_hours->at_work;

ditto

> Comments/Thoughts/...?

I think you're mixing two sets of functionality.

The first thing we need is a "business calendar" module that lets us
define standard work days/hours, days off, and partial days.

It should also be able to do calculations like, tell us how many business
days occur between two dates, how many business hours/minutes occur
between two datetimes, and generally let us do "business datetime math".

Then we can use that module in another module that implements the
per-employee stuff you're interested in.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to