#!/usr/bin/perl -w my $usage = "Usage: $0 -a [-][hh:][mm:]ss"; use Date::Calc qw( Decode_Date_US Add_Delta_DHMS Delta_DHMS); my($option,$adj) = (shift,shift); $option eq "-a" or die $usage; my ($adjsec) = &hhmmss_toseconds($adj) or die $usage; print STDERR "adjusting by $adjsec seconds\n"; while(<>) { ### 48778 Thu Feb 22 15:42:39 2001 546.jpg chomp; my ($size,$day,$mo,$date,$time,$year,$file) = split; ### print STDERR "time is $time\n"; my ($timesec) = &hhmmss_toseconds($time); ### print STDERR "timesec is $timesec\n"; ($time) = &seconds_tohmmss($timesec+$adjsec); print join(' ',$size,$day,$mo,$date,$time,$year,$file),"\n"; } exit; sub hhmmss_toseconds { my ($t) = @_; my $sign = ($t =~ s|^\s*-||) ? -1 : +1; if ($t =~ m|^([\d]+):([\d]+):([\d\.]+)$|) { $t = 3600*$1 + 60*$2 + $3; } elsif ($t =~ m|^([\d]+):([\d\.]+)$|) { $t = 60*$1 + $2; } else { die "hhmmss_toseconds: bad arg <$t> sign <$sign>"; } return ($sign*$t); } sub seconds_tohmmss { my ($t) = @_; ### print STDERR "stoh: $t\n"; my (undef,undef,$day,$hour,$minute,$second) = Add_Delta_DHMS(1,1,1,0,0,0,0,0,0,$t); return (sprintf("%02i:%02i:%02i",$hour,$minute,$second)); if($hour) { $t = sprintf("%i:%02i:%02i",$hour,$minute,$second) } elsif ($minute) { $t = sprintf("%i:%02i",$minute,$second) } else { $t = sprintf("%i",$second) } return ($t); } sub pretty_date { return (join('/',$_[1],$_[2],$_[0]).' '.sprintf("%02i:%02i:%02i",@_[3..$#_])); }