Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Time Issues

by chipmunk (Parson)
on Dec 01, 2000 at 19:29 UTC ( [id://44377]=note: print w/replies, xml ) Need Help??


in reply to Time Issues

Here's a basic solution using only core modules:
use Time::Local; $date = '30Nov00'; my @months = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; my $i = 0; my %months = map { $_ => $i++ } @months; my @dmy = $date =~ /(\d+)([A-Z]+)(\d+)/i; $dmy[1] = $months{$dmy[1]}; if ($dmy[2] < 60) { # have to handle two-digit $dmy[2] += 100; # year somehow } my $time = timelocal(0, 0, 12, @dmy); # noon, to avoid DST issues $time += 60 * 60 * 24; # advance one day my @dmy = (localtime($time))[3, 4, 5]; $dmy[1] = $months[$dmy[1]]; $dmy[2] %= 100; my $date2 = sprintf "%02d%s%02d", @dmy; print "$date2\n";

Of course, you could have Date::Parse and Date::Manip do most of the work for you, if you wanted.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found