Re: Convert string into incremental date



djray wrote:
My question is two part:
1. I am reading a date from a file in the form mm/dd/yy (i.e.
05/30/06). I need to convert that string into a date.
2. I need to be able to increment that date:
Example:
$date = 05/30/06;
$date = $date + 1; ($date = 05/31/06)
$date = $date + 1; ($date = 06/01/06)

Any help would be greatly appreciated.

-Ray

This might get you started :-)

use strict;
use warnings;
use DateTime;
use DateTime::Duration;
use DateTime::Format::Strptime;

my $Strp = new DateTime::Format::Strptime(
pattern => '%m/%d/%y',
time_zone => 'GMT',
);
my $dur = DateTime::Duration->new( days => 1 );

while (<DATA>) {
chomp;
my $dt = $Strp->parse_datetime($_);
print $dt + $dur;
}
__DATA__
05/31/06
06/01/06


I hope this helps

Mothra


.



Relevant Pages

  • Re: Convert string into incremental date
    ... djray wrote: ... I am reading a date from a file in the form mm/dd/yy (i.e. ... I need to convert that string into a date. ...
    (comp.lang.perl.misc)
  • Re: Convert string into incremental date
    ... djray wrote: ... I am reading a date from a file in the form mm/dd/yy (i.e. ... I need to convert that string into a date. ...
    (comp.lang.perl.misc)
  • Re: Convert string into incremental date
    ... Mothra wrote: ... I am reading a date from a file in the form mm/dd/yy (i.e. ... I need to convert that string into a date. ...
    (comp.lang.perl.misc)
  • Convert string into incremental date
    ... I am reading a date from a file in the form mm/dd/yy (i.e. ... I need to convert that string into a date. ... I need to be able to increment that date: ...
    (comp.lang.perl.misc)
  • Re: Cross domain iframe access
    ... and WebKit do not allow to read back the `location' string value ... Such that any attempt to read the - toString - property, or if it can be read then to execute its value, may be the point at which a security exception is thrown. ... Other forms of direct access to the - location - object certainly can stand as a demonstration that reading its value is not subject to any security restrictions. ...
    (comp.lang.javascript)