Determine weekends and compare two days

P

Prak

I'm not much of a perl programmer so I was hoping someone could help
me. What I need to do is determine between 2 dates whether there is a
weekend between them inclusive.

eg Between 1 Oct 2004 and 4 Oct 2004 there is a Sat. and a Sunday but
between 5 Oct 2004 and 8 Oct 2004, there is no Sat or Sunday.

Thanks in advance
Prak
 
J

Julia De Silva

I'm not much of a perl programmer so I was hoping someone could help
me. What I need to do is determine between 2 dates whether there is a
weekend between them inclusive.

eg Between 1 Oct 2004 and 4 Oct 2004 there is a Sat. and a Sunday but
between 5 Oct 2004 and 8 Oct 2004, there is no Sat or Sunday.

Thanks in advance
Prak

You really ought to try working this one out on your own! That way you'll
understand and improve. Here's a pointer.

use Time::localtime;
my $today = time;
my $day_of_week = localtime($today)->wday;
my @days_of_week = qw(Sun Mon Tues Wed Thur Fri Sat);
print"Today is $days_of_week[$day_of_week]\n";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top