develooper Front page | perl.datetime | Postings from March 2017

Re: Recurring set does not correctly calculate dates for secondFriday of the month.

Thread Previous
From:
Flavio S. Glock
Date:
March 2, 2017 01:47
Subject:
Re: Recurring set does not correctly calculate dates for secondFriday of the month.
Message ID:
CAHMRfDwFx1BEMVoR=MZF=n27uvPGd3tXrQgd2JUL4PWjaeOwtw@mail.gmail.com
please check the week_start_day parameter, I believe it will fix
this problem:

http://search.cpan.org/~fglock/DateTime-Event-Recurrence-0.18/lib/DateTime/Event/Recurrence.pm#The_%22week_start_day%22_Parameter

Em terça-feira, 28 de fevereiro de 2017, Andrew Martin <andrew@marnick.com>
escreveu:

> Hi,
>
> The following code produces (for me) this output.. ( dd-mm-yyyy)
>
> 13-01-2017 Test event
> 17-02-2017 Test event
> 17-03-2017 Test event
> 14-04-2017 Test event
> 12-05-2017 Test event
> 16-06-2017 Test event
> 14-07-2017 Test event
> 18-08-2017 Test event
> 15-09-2017 Test event
> 13-10-2017 Test event
> 17-11-2017 Test event
> 15-12-2017 Test event
>
> Some of these dates are correct e.g. 14-04-2017 is the second Friday of
> April 2017,
>
> however 17-02-2017 is the Third Friday, the expected result is 10-02-2017
>
>
> I would appreciate any help, I'm baffled :-)
>
>
> Kind regards,
>
>
> Andrew Martin
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use DateTime;
> use DateTime::Event::Recurrence;
> my $year=2017;
> my $event="Test event";
>
> my $dt1 = DateTime->new( year   => $year,
>                      month  => 1,
>                      day    => 1,
>                    );
>
> my $dt2 = DateTime->new( year   => $year,
>                      month  => 12,
>                      day    => 31,
>                    );
>
> my $set = DateTime::Event::Recurrence->monthly( weeks => 2, days =>5
> );
>         my @days = $set->as_list( start => $dt1, end => $dt2 );
>
>         foreach my $d (@days){
>             print $d->dmy . " $event\n";
>         }
>
>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About