Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: What is the best way to get a list of all Mondays until the end of the year?

by ForgotPasswordAgain (Deacon)
on Aug 19, 2008 at 11:06 UTC ( #705168=note: print w/ replies, xml ) Need Help??


in reply to What is the best way to get a list of all Mondays until the end of the year?

Play with this:

perl -MDateTime -le'$min=DateTime->now;$max=DateTime->new(year=>2008,m +onth=>12,day=>31);while($min->dow != 1){$min->add(days=>1)};while($mi +n<$max){print $min->ymd; $min->add(weeks=>1)}'


Comment on Re: What is the best way to get a list of all Mondays until the end of the year?
Download Code
Re^2: What is the best way to get a list of all Mondays until the end of the year?
by Anonymous Monk on Aug 19, 2008 at 11:50 UTC
    #!/usr/bin/perl -- use strict; use warnings; use DateTime::Event::Recurrence; { my $dt1 = new DateTime( year => 2008 ); my $dt2 = new DateTime( year => 2009 ); my $der = DateTime::Event::Recurrence->weekly; print $_->ymd, ' ', ,$/ for $der->as_list( start => $dt1, end => $dt2 ); } # http://datetime.perl.org/index.cgi?FAQDurationsSetsSpans __END__
    2008-01-07 2008-01-14 2008-01-21 2008-01-28 2008-02-04 2008-02-11 2008-02-18 2008-02-25 2008-03-03 2008-03-10 2008-03-17 2008-03-24 2008-03-31 2008-04-07 2008-04-14 2008-04-21 2008-04-28 2008-05-05 2008-05-12 2008-05-19 2008-05-26 2008-06-02 2008-06-09 2008-06-16 2008-06-23 2008-06-30 2008-07-07 2008-07-14 2008-07-21 2008-07-28 2008-08-04 2008-08-11 2008-08-18 2008-08-25 2008-09-01 2008-09-08 2008-09-15 2008-09-22 2008-09-29 2008-10-06 2008-10-13 2008-10-20 2008-10-27 2008-11-03 2008-11-10 2008-11-17 2008-11-24 2008-12-01 2008-12-08 2008-12-15 2008-12-22 2008-12-29
      one-liner version
      perl -MDateTime::Event::Recurrence -le " print $_->ymd, chr(32) for +DateTime::Event::Recurrence->weekly->as_list( start => DateTime->new +( year => 2008 ), end => DateTime->new ( year => 2009 ) ); " perl -MDateTime::Event::Recurrence -le ' print $_->ymd, chr(32) for +DateTime::Event::Recurrence->weekly->as_list( start => DateTime->new +( year => 2008 ), end => DateTime->new ( year => 2009 ) ); '

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://705168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2014-08-31 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls