[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [MacPerl] How do I find the day of the week from a given date (NOT today)



I think that this can be simplified to:

-----
#!perl -w 
use Date::Manip;

my $date = ParseDateString("15 Mar 1999");
print UnixDate($date, "%A");
-----

This is a useful module.

Greg

> -----Original Message-----
> From:	Arved Sandstrom [SMTP:Arved_37@chebucto.ns.ca]
> Sent:	Thursday, March 11, 1999 4:50 AM
> To:	Lars G. Skjellerup
> Cc:	MacPerl - List
> Subject:	Re: [MacPerl] How do I find the day of the week from a given
> date (NOT today)
> 
> On Thu, 11 Mar 1999, Lars G. Skjellerup wrote:
> 
> > I have a small problem (Yet again). How can I find the day of the week
> > from a given date, which is not the date today. If it was the date now
> > it is real easy.
> > 
> > Are there some pearl functions other than localtime(),time() - that
> > might be helpful ? Or do I have to construct my own ?
> > 
> There is always the monolithic, all-capable Date::Manip module. :-)
> 
> I don't use it myself, so the following is a cobble, and parts may be
> round-about, but it works:
> 
> #!perl -w
> 
> use Date::Manip; 
> 
> $date=&ParseDateString("15 Mar 1999");
> $unixdate = &UnixDate($date, "%m %d %y");
> ($m, $d, $y) = split(/ /,$unixdate);
> $day=&Date_DayOfWeek($m,$d,$y); 
> 
> @daynames = ("","Mon","Tue","Wed","Thu","Fri","Sat","Sun"); 
> print "Day = $daynames[$day]\n";
> 
> __END__
> 
> 
> 
> ===== Want to unsubscribe from this list?
> ===== Send mail with body "unsubscribe" to macperl-request@macperl.org

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org