For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > September 2006 > print out a list of all dates?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author print out a list of all dates?
ewaguespack@gmail.com

2006-09-01, 6:57 pm

i would like to print out a list of all of the dates in a year in the
following syntax

January_01 (or January_1)
....
March_28
....
December_31

any ideas? thanks


oh... by the way I would want to include leap-year

usenet@DavidFilmer.com

2006-09-01, 6:57 pm

ewaguespack@gmail.com wrote:
> i would like to print out a list of all of the dates in a year in the
> following syntax
>
> January_01


A date module like Date::Manip will simplify your life:

#!/usr/bin/perl
use strict; use warnings;
use Date::Manip;

foreach my $date( ParseRecur( "every day", undef,
'2006/01/01', '2006/12/31')) {
print UnixDate($date, "%B_%d"), "\n";
}

__END__


> (or January_1)


print UnixDate($date, "%B_%e"), "\n";

> oh... by the way I would want to include leap-year


The module figures all of that out for you as needed.

--
David Filmer (http://DavidFilmer.com)

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com