Rick Measham wrote:
> 
> 6.12 is listed as TODO, here is my solution. Is there a better way to
> do it? If there's no better way is it worth making some sort of module
> -- although I'm not sure what to call it!
> 
> Step four can be removed if we reword the question to remove the part
> about 'days'.
> 
> Cheers!
> Rick
> 

Another way:
---

# FAQ 6.12

use strict;

use DateTime;
use DateTime::Span;
use DateTime::Event::Recurrence;
use DateTime::Format::Duration;

# 1. Get the span including weekends

my $span = DateTime::Span->from_datetime_and_duration(
        start => DateTime->now(),
        days  => 7,
);

# 2. Get a set of the non-weekends

my $week_days = DateTime::Event::Recurrence->weekly(
    days => [ 1 .. 5 ]
);

# 3. Intersect 2 and 1

my $relevant_set = $week_days->intersection( $span );


# 4. Report the result

printf "The span contains %s weekdays.",
        $relevant_set->count;

__END__


- Flavio S. Glock

Reply via email to