Re: Subtracting Weekends and Holidays from a SpanSet

2006-07-11 Thread Flavio S. Glock

11 Jul 2006 06:19:21 -0700, Rick <[EMAIL PROTECTED]>:

I am working on developing a system that calculates the time worked on
my company's projects.   For each project I have a SpanSet representing
the time reportedly worked on each project  and need to eliminate all
time for weekends and work holidays.

My approach has been to build a spanset for the weekends and holidays
and use the 'complement' function to remove that time from the project.


 $slatime = $project_spanset->complement(
$weekends_and_holidays_spanset );

This works fine, but it is terribly slow on my system.  It takes over
one seconds per project to compute, and we have over 10,000 projects.

Is there a way to speed it up given that we are ONLY working with full
days? (i.e. the weekends and holidays we are trying to subtract are
complete days)


Sets are not easily optimizable, sorry.
You may have to use plain old arrays, pre-calculate the values and use
grep or a for-loop.

OTOH, the grep() method in DateTime::Set may be useful in this case.

   # example: filter out any sundays
   $set = $set2->grep(
   sub {
   return ( $_->day_of_week != 7 );
   }
   );

- Flavio S. Glock


Subtracting Weekends and Holidays from a SpanSet

2006-07-11 Thread Rick
I am working on developing a system that calculates the time worked on
my company's projects.   For each project I have a SpanSet representing
the time reportedly worked on each project  and need to eliminate all
time for weekends and work holidays.

My approach has been to build a spanset for the weekends and holidays
and use the 'complement' function to remove that time from the project.


 $slatime = $project_spanset->complement(
$weekends_and_holidays_spanset );

This works fine, but it is terribly slow on my system.  It takes over
one seconds per project to compute, and we have over 10,000 projects.

Is there a way to speed it up given that we are ONLY working with full
days? (i.e. the weekends and holidays we are trying to subtract are
complete days)

Thanks!!!

Rick Ferrante