Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Englishy Date Translations

by cidaris (Friar)
on Jul 15, 2002 at 19:05 UTC ( #181879=perlquestion: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://181879]
Approved by VSarkiss
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2023-06-02 12:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found