By using day of the week out of locatime, you should be able to determine how
many days you need to add to get to Monday.
Example: Thu is 4 and Mon is 1. So if always looking for the next Monday, then
you can do something like:
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time);
$mon++;
# have the current date
my $MyMonday = 1; # if Sunday need to only add 1 to day
of week to get mon
# Assuming if Monday then you
want the next Monday
# So by doing a subtraction of
$wday from 8, you
# will get the number of days
need to calculate the
# next Monday
$MyMonday = 8 - $wday if ( $wday );
my $MyDays = $MyMonday * 86400;
($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time + $MyDays);
$mon++;
# now have next Mondays
Wags ;)
-----Original Message-----
From: Shinagare, Sandeep [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 06, 2001 09:06
To: [EMAIL PROTECTED]
Subject: Getting next Monday...
Hi All,
I am trying to find the date, month and year of the next Monday given any
day.
I am using this to get todays date/day/month etc. Is there a way to use
this
information to get the next Monday?
#snip-start
$thisday=(Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime)[6]];
$thisdate=(localtime)[3];
$thismonth=(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sept,Oct,Nov,Dec)[(localtime)[4]
];
$thisyear=(localtime)[5] + 1900;
#snip-end
Thanks,
Sandeep
**********************************************************************
COLT Telecommunications
Registered in England No. 2452736
Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ
Tel. 020 7390 3900
This message is subject to and does not create or vary any contractual
relationship between COLT Telecommunications, its subsidiaries or
affiliates ("COLT") and you. Internet communications are not secure
and therefore COLT does not accept legal responsibility for the
contents of this message. Any view or opinions expressed are those of
the author. The message is intended for the addressee only and its
contents and any attached files are strictly confidential. If you have
received it in error, please telephone the number above. Thank you.
************************************************************************
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]