class TestCase::Time::Local {
  use Sys;
  use Sys::Time::Tm;
  use Time::Local;
  
  static method timelocal : int () {
    {
      my $epoch = Sys::Time->time();
      
      my $tm = Sys->localtime($epoch);
      
      my $epoch_ret = Time::Local->timelocal($tm);
      
      unless ($epoch_ret isa long) {
        return 0;
      }
      unless ($epoch == $epoch_ret) {
        return 0;
      }
    }
    
    return 1;
  }

  static method timegm : int () {
    {
      my $epoch = Sys::Time->time();
      
      my $tm = Sys->gmtime($epoch);
      
      my $epoch_ret = Time::Local->timegm($tm);

      unless ($epoch_ret isa long) {
        return 0;
      }
      unless ($epoch == $epoch_ret) {
        return 0;
      }
    }

    {
      my $epoch = Sys::Time->time();
      
      my $tm = Sys->gmtime($epoch);
      
      my $new_tm = Sys->localtime(0);
      
      $new_tm->set_tm_sec($tm->tm_sec);
      $new_tm->set_tm_min($tm->tm_min);
      $new_tm->set_tm_hour($tm->tm_hour);
      $new_tm->set_tm_mday($tm->tm_mday);
      $new_tm->set_tm_mon($tm->tm_mon);
      $new_tm->set_tm_year($tm->tm_year);
      
      my $epoch_again = Time::Local->timelocal($new_tm);
      
      warn "[Test Output]timegm:to local:$epoch $epoch_again";
      
      my $epoch_diff = $epoch - $epoch_again;
      
      warn $epoch_diff;

=pod TODO This test depends on TZ environment variable

      my $epoch_diff_hour = $epoch_diff / 60 / 60;
      
      unless ($epoch_diff_hour == 9) {
        return 0;
      }

=cut

    }
    
    return 1;
  }

}
