If you are using Activestate Perl, Date::Calc should be part of your standard distribution. If it is not part of your distribution, you can get it from CPAN. It has a lot of very useful functions. Look through it to see what all it has.

 

Using Date::Calc, here is one way you could do what you have asked:

 

use Date::Calc qw(:all);

my $date =
'25/11/2003';

my @dateparts = split
m#\/#, $date;

# call the function from Date::Calc using arguments Year, Month, Day
my $dow = Day_of_Week(@dateparts[2, 1, 0]);

# print numeric day of week:

print $dow .
"\n";

# make an array for day names:

my @days =
qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);

print
"The day of the week for $date is $days[$dow]\n"

 

-----Original Message-----
From: Cruickshanks, Darin [mailto:darin@essex.ac.uk]
Sent: Friday, October 17, 2003 3:43 AM
To: perl-win32-gui-users@lists.sourceforge.net
Subject: [perl-win32-gui-users] Quick Question

 

All,

 

This shouldn't really go to this list but here goes.

 

I have a script where a user will enter a date in this format   25/11/2003

 

Does anyone know of a way with Perl to get the 'day' from this?  (Mon,Tue etc)

 

Darin

--------------------------------------------

Darin Cruickshanks
Labs Manager, Computing Service
University of Essex
darin@essex.ac.uk
01206 873585

 

- This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. - If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.