Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: Adding Days To YYYYMMDD Date Format

by tobyink (Canon)
on Aug 10, 2012 at 21:49 UTC ( [id://986830]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Adding Days To YYYYMMDD Date Format
in thread Adding Days To YYYYMMDD Date Format

use 5.010; use strict; use warnings FATAL => qw(all); use DateTimeX::Auto qw(:auto); { # slightly evil, but works... package DateTime; use overload '~~', sub { $_[0]->ymd eq $_[1]->ymd } } my $not_business_days = [ sub { $_[0]->day_abbr =~ /^S/ }, # weekends qw( 2012-01-02 2012-04-06 2012-04-09 2012-05-07 2012-06-04 2012-06-05 2012-08-27 2012-12-25 2012-12-26 ), ]; my $date = '2012-01-01'; my $end = '2013-01-01'; while ($date < $end) { say $date->ymd("") unless $date ~~ $not_business_days; $date->add(days => 1); }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found