Personally I find understanding Date::Manip::Recur patterns a bit too complicated for my taste. I prefer DateTime::Set - more verbose of course, but IMHO better understandable and therefore more maintainable and reusable:

use warnings; use strict; use DateTime; use DateTime::Set; my $fridays = DateTime::Set->from_recurrence( start => DateTime->new( year=>2020, month=>1, day=>1 ), before => DateTime->new( year=>2020, month=>6, day=>1 ), recurrence => sub { my $dt = shift; return $dt if $dt->is_infinite; if ( $dt->dow>5 ) { $dt->add(days=>12-$dt->dow) } elsif ( $dt->dow<5 ) { $dt->add(days=> 5-$dt->dow) } else { $dt->add(weeks=>1) } die $dt unless $dt->dow==5; # double-check return $dt; } ); my $iter = $fridays->iterator; while ( my $dt = $iter->next ) { print $dt->strftime("%A, %B %e %Y"), "\n"; } __END__ Friday, January 3 2020 Friday, January 10 2020 Friday, January 17 2020 Friday, January 24 2020 Friday, January 31 2020 Friday, February 7 2020 Friday, February 14 2020 Friday, February 21 2020 Friday, February 28 2020 Friday, March 6 2020 Friday, March 13 2020 Friday, March 20 2020 Friday, March 27 2020 Friday, April 3 2020 Friday, April 10 2020 Friday, April 17 2020 Friday, April 24 2020 Friday, May 1 2020 Friday, May 8 2020 Friday, May 15 2020 Friday, May 22 2020 Friday, May 29 2020

In reply to Re: Date::Manip ParseRecur help needed by haukex
in thread Date::Manip ParseRecur help needed by cormanaz

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.