Here's one way using DateTime.pm and DateTime::Event::Cron, though it does not take into account holidays and assumes Mon-Fri 8 hrs per day. <shrug> :
use strict; use warnings; use DateTime; my $start_date = DateTime->now(); my $end_date = $start_date + DateTime::Duration->new(months => 2); print $start_date->datetime, "\n", $end_date->datetime, "\n\n"; use DateTime::Event::Cron; my $crontab = '0 0 * * 1-5'; my $set = DateTime::Event::Cron->from_cron( cron => $crontab, start => $start_date, before => $end_date # to include $end_date, use 'end' rather than 'before' ); my @weekdays = $set->as_list; print scalar @weekdays, " weekdays : ", scalar @weekdays * 8, " work h +ours\n";

Cheers,
Matt


In reply to Re: determining work hours between 2 dates by mojotoad
in thread determining work hours between 2 dates by kosie99

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.