in reply to Date to Day

It's a little involved but it should get you going. There are *many* more excellent and speedy routines in Date::Calc.

use Date::Calc qw( Today Add_Delta_Days Day_of_Week_to_Text Day_of_Week ); my @today = Today(); my $days_in_the_future = shift || 0; my @then = Add_Delta_Days( @today, $days_in_the_future ); print Day_of_Week_to_Text( Day_of_Week( @then ) ), "\n";

Replies are listed 'Best First'.
Re^2: Date to Day
by blokhead (Monsignor) on Aug 25, 2004 at 21:40 UTC
    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

      Wow! I didn't know that you could use the localtime function in that way. This is very useful. Thanks! Joe
Re^2: Date to Day
by JoeJaz (Monk) on Aug 25, 2004 at 21:52 UTC
    I'll have a look into that. Though I generally try to shy away from modules, this one seems worth the extra install. Thanks for pointing me to it. I appreciate your help. Joe

      If you want to install a Date and Time handling module then you should really be looking at the ones from the DateTime Project as they aim to cover all of the functionality of the current diverse set of modules with one coherent set of modules.

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

      *sigh* Ignore this.