cidaris has asked for the wisdom of the Perl Monks concerning the following question:

I am working on a way to convert "3rd Sunday in March" and "2nd Friday in April" kind of dates to something a machine can use. I have the -long- code to do it, using arrays and math, but I was looking for a module somewhere?
The few that I'm familiar with don't seem to do this kind of thing.
I've used Date::Calc and things like that, and are comfortable with them, but I guess I just don't know what to call this kind of classification to look further.


Replies are listed 'Best First'.
Re: Englishy Date Translations
by fglock (Vicar) on Jul 15, 2002 at 19:55 UTC

    Date::Tie can do the math part:

    use strict; use Date::Tie; tie my %date, "Date::Tie"; # 3rd Sunday in March $date{month} = 3; # march is 3 $date{day} = 1; # start counting form march first $date{weekday} = 7; # monday is 1, sunday is 7 $date{week} += 2; # advance 2 weeks print "3rd Sunday in March is $date{month}-$date{day}\n"; # 2nd Friday in April $date{month} = 4; # april is 4 $date{day} = 1; # start counting form april first $date{weekday} = 5; # monday is 1, friday is 5 $date{week} += 1; # advance 1 week print "2nd Friday in April is $date{month}-$date{day}\n";


    3rd Sunday in March is 03-17 2nd Friday in April is 04-12

    update: Date::Tie is fast

•Re: Englishy Date Translations
by merlyn (Sage) on Jul 15, 2002 at 19:20 UTC
Re: Englishy Date Translations
by artist (Parson) on Jul 15, 2002 at 20:19 UTC