#!/usr/bin/perl -I/usr/lib/perl5/5.10.0

#use Time::CTime;
#use Time::gmtime;
#use File::Find;

use POSIX qw(strftime);

#$dir=$ARGV[0];
$file1=$ARGV[0];
$file2=$ARGV[1];
$delta=0;

  ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size1,$atime1,$mtime1,$ctime1,$blksize,$blocks)=stat "$file1";
  $mtm=strftime("%Y-%m-%d-%H-%M-%S",localtime($mtime1));
  $ctm=strftime("%Y-%m-%d-%H-%M-%S",localtime($ctime1));
  $atm=strftime("%Y-%m-%d-%H-%M-%S",localtime($atime1));
# printf "%s %d %d %d \n", $file1, $ctime1, $mtime1, $size1;

  ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size2,$atime2,$mtime2,$ctime2,$blksize,$blocks)=stat "$file2";
  $mtm2=strftime("%Y-%m-%d-%H-%M-%S",localtime($mtime2));
  $ctm2=strftime("%Y-%m-%d-%H-%M-%S",localtime($ctime2));
  $atm2=strftime("%Y-%m-%d-%H-%M-%S",localtime($atime2));
# printf "%s %d %d %d \n", $file2, $ctime2, $mtime2, $size2;

  $delta=($mtime2 - $mtime1)/60;
  $sizechg=($size2/$size1)*100 - 100;
  if ( $sizechg > 0 ){
    $sizechgstr=sprintf("+%d%%", $sizechg);
  }
  else {
    $sizechgstr=sprintf("%d%%", $sizechg);
  }

# printf "Size(MB):%7.2f/%7.2f dt(min):%d \n", $size1/1000000, $size2/1000000, $delta;
  
  if ($size1 > 1000000) {
    $s1=sprintf("%7.2f MB", $size1/1000000);
  }
  elsif ($size1 > 1000) {
    $s1=sprintf( "%7.2f KB", $size1/1000);
  }
  else {
    $s1=$size1;
  }
  if ($size2 > 1000000) {
    $s2=sprintf( "%7.2f MB", $size2/1000000);
  }
  elsif ($size2 > 1000) {
    $s2=sprintf( "%7.2f KB", $size2/1000);
  }
  else {
    $s2=$size2;
  }

  if ($delta <= 0) {
    printf "Size:%s/%s %s  dt(min): %d \n", $s1, $s2, $sizechgstr, $delta;
  }
  else {
    printf "Size:%s/%s %s  dt(min): +%d \n", $s1, $s2, $sizechgstr, $delta;
  }

exit 0;
