Changeset 2415

Show
Ignore:
Timestamp:
01/11/08 05:03:53
Author:
miyagawa
Message:

apply the patch from trs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Time-Duration-Parse/trunk/lib/Time/Duration/Parse.pm

    r2410 r2415  
    2626    } 
    2727 
     28    # Convert hh:mm(:ss)? to something we understand 
     29    $timespec =~ s/\b(\d+):(\d\d):(\d\d)\b/$1h $2m $3s/g; 
     30    $timespec =~ s/\b(\d+):(\d\d)\b/$1h $2m/g; 
     31 
    2832    my $duration = 0; 
    2933    while ($timespec =~ s/^\s*(-?\d+)\s*([a-zA-Z]+)(?:\s*(?:,|and)\s*)*//i) { 
     
    3842    } 
    3943 
    40     if ($timespec) { 
     44    if ($timespec =~ /\S/) { 
    4145        Carp::croak "Unknown timespec: $timespec"; 
    4246    } 
  • Time-Duration-Parse/trunk/t/01_parse.t

    r2390 r2415  
    11use strict; 
    2 use Test::More tests => 17
     2use Test::More tests => 22
    33 
    44use Time::Duration::Parse; 
     
    3131ok_duration '1hr', 3600; 
    3232 
     33ok_duration '1d 2:03', 93780; 
     34ok_duration '1d 2:03:01', 93781; 
     35ok_duration '1d -24:00', 0; 
     36ok_duration '2:03', 7380; 
     37 
     38ok_duration ' 1s   ', 1; 
     39 
    3340fail_duration '3 sss'; 
    3441fail_duration '6 minutes and 3 sss';