Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Adding Days To YYYYMMDD Date Format

by tobyink (Canon)
on May 17, 2012 at 22:36 UTC ( [id://971185]=note: print w/replies, xml ) Need Help??


in reply to Adding Days To YYYYMMDD Date Format

use DateTimeX::Auto qw(:auto); my $date = '2012-05-16'; $date->add(days => 24); print "$date\n";
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Adding Days To YYYYMMDD Date Format
by Kenosis (Priest) on May 18, 2012 at 22:51 UTC

    This is elegant and very readable, tobyink! Nice work...

      I meant to add... I've uploaded a new version of DateTimeX::Auto so now it's possible to just do:

      use DateTimeX::Auto qw(:auto); my $future = '2012-05-19' + 'P3Y4M2D'; # says '2015-09-21' say $future;

      The duration format isn't the most readable, but it's an ISO standard (ISO 8601 duration), so fairly well documented if you Google for it.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
        That *::Auto has more magic than *::Easy! And, MooseX::Types::DateTimeX lists the caveat about *::Easy that it has too much DWIMery.
        I have a similar issue. Is there a way to construct a for loop that will generate dates in format YYYMMDD starting on the first business date of the year and skip Saturdays and Sundays?

        Example, 20120103 20120104 20120105 20120106 20120109 20120110 20120111 20120112 etc.

Log In?
Username:
Password:

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

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

    No recent polls found