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: Learning the fretboard..
    ... Sight reading at a higher level entails recognition of musical ... is your default handling of two whole steps along a string, ... -Start with a major triad, in root position, with the root on the ... There is only one way to play this triad. ...
    (rec.music.classical.guitar)