in reply to Re: Date to Day
in thread Date to Day

Well, if the OP already has the number of days in the future, it can be a lot simpler:
my $today_wday = (localtime)[6]; my $then_wday = ($today_wday + $days_in_the_future) % 7;
Update: But it sounds like he's just given a date string. If it's a simple MM-DD-YYYY, I'd suggest Time::Local+localtime, since it's core.
use Time::Local; my $string = "01-01-2015"; my ($m, $d, $y) = split /-/, $string; my $epoch = timelocal 0, 0, 0, $d, $m-1, $y-1900; my $wday = (localtime $epoch)[6];
To do any of the other algorithms suggested, you'll need to parse out the day, month, year values anyway.. If this is a problem, you will need a beefier date module like Date::Calc.

blokhead

Replies are listed 'Best First'.
Re^3: Date to Day
by JoeJaz (Monk) on Aug 25, 2004 at 22:10 UTC
    Wow! I didn't know that you could use the localtime function in that way. This is very useful. Thanks! Joe