Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Date formatting

by dragonchild (Archbishop)
on Jun 30, 2003 at 13:10 UTC ( [id://270157]=note: print w/replies, xml ) Need Help??


in reply to Date formatting

If you're doing more than that, I would suggest looking at Date::Manip and Date::Calc.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Date formatting
by davorg (Chancellor) on Jun 30, 2003 at 14:14 UTC

    Why bother loading external (and very large and slow) modules when this is really a text processing problem that can be solved very easily with standard Perl functions?

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

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

      "If you're doing more than that" ... where "that" implies your original reply.

      While Date::Manip is large and slow and all things horrible ... Perl is large and slow and all things horrible too! If you're looking for execution speed, go to ASM. If you're looking for development speed, use the appropriate modules. Personally, I don't think the OP wanted the fastest solution. I believe he (and nearly everyone who posts on PM) is looking for the easiest solution. Both solutions are easy. Yours is easier in that it doesn't require learning how to use modules. Date::Manip is easier when the requirements change, like they always do.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

        Fair point. But in that case I'd be far more likely to suggest that people used something like DateTime or one of the other modules from the Perl date/time project.

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

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

Re: Re: Date formatting
by xdg (Monsignor) on Jun 30, 2003 at 14:00 UTC

    More specifically, with Date::Manip, you can parse and reformat with a single function call:

    $ perl -MDate::Manip -le 'print UnixDate("06/07/2003","%Y-%m-%d");' 2003-06-07

    -xdg

    Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://270157]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-03-29 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found