"Fossies" - the Fresh Open Source Software Archive

Member "PerlCDF38_0/testtime.pl" (19 Nov 2019, 2619 Bytes) of package /linux/misc/PerlCDF38_0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "testtime.pl" see the Fossies "Dox" file reference documentation.

    1 #!/usr/bin/perl -w
    2 use strict;
    3 use Math::BigInt;
    4 
    5 BEGIN { unshift @INC,'/home/liu/PerlCDF38_0/blib/arch',
    6                      '/home/liu/PerlCDF38_0/blib/lib'; }
    7 use CDF;
    8 
    9 print "\nTesting EPOCH.....\n";
   10 
   11 my $year = 1970;
   12 my $month = 1;
   13 my $day = 1;
   14 my $hour = 0;
   15 my $minute = 0;
   16 my $second = 0;
   17 my $msec = 987;
   18 my $str;
   19 
   20 my $epoch = CDF::computeEPOCH ($year, $month, $day, $hour, $minute,  
   21                                $second, $msec);
   22 CDF::toEncodeEPOCH($epoch, 4, $str);
   23 print "epoch=$str\n";
   24 
   25 my $unixTime;
   26 my @unixTimes;
   27 my @epochs;
   28 # print "ref of epoch = ref($epoch)\n";
   29 print "epoch=$epoch\n";
   30 CDF::EPOCHtoUnixTime ($epoch, $unixTime);
   31 print  "unixtime=$unixTime\n";
   32 my $u1;
   33 CDF::UnixTimetoEPOCH ($unixTime, $u1);
   34 print  "u1=$u1\n";
   35 CDF::toEncodeEPOCH($u1, 4, $str);
   36 print "$str\n";
   37 
   38 $epochs[0] = $epoch;
   39 $epochs[1] = $epoch+1000.0;
   40 
   41 CDF::EPOCHtoUnixTime (\@epochs, \@unixTimes);
   42 print  "epoch=$epochs[0] $epochs[1]\n";
   43 print  "unixtime=$unixTimes[0] $unixTimes[1]\n";
   44 
   45 my @newepochs;
   46 my @strs;
   47 CDF::UnixTimetoEPOCH (\@unixTimes, \@newepochs);
   48 CDF::toEncodeEPOCH(\@newepochs, 4, \@strs);
   49 print "0: $strs[0]\n";
   50 print "1: $strs[1]\n";
   51 
   52 print "\nTesting TT2000.....\n";
   53 my $tt2000 = CDF::computeTT2000 ($year, $month, $day, $hour, $minute,  
   54                                  $second, $msec, 234, 567);
   55 CDF::toEncodeTT2000($tt2000, 4, $str);
   56 print "tt2000=$str\n";
   57 
   58 my @tt2000s;
   59 # print "ref of tt2000 = ref($tt2000)\n";
   60 print "tt2000=$tt2000\n";
   61 CDF::TT2000toUnixTime ($tt2000, $unixTime);
   62 print  "unixtime=$unixTime\n";
   63 CDF::UnixTimetoTT2000 ($unixTime, $u1);
   64 print  "$tt2000 => $unixTime => $u1\n";
   65 CDF::toEncodeTT2000($u1, 4, $str);
   66 print "tt2000=$str\n";
   67 
   68 $tt2000s[0] = $tt2000;
   69 $tt2000s[1] = $tt2000+1000000000.0;
   70 
   71 CDF::TT2000toUnixTime (\@tt2000s, \@unixTimes);
   72 print  "tt2000=$tt2000s[0] $tt2000s[1]\n";
   73 print  "unixtime=$unixTimes[0] $unixTimes[1]\n";
   74 my @newtt2000s;
   75 CDF::UnixTimetoTT2000 (\@unixTimes, \@newtt2000s);
   76 print  "newtt2000=$newtt2000s[0] $newtt2000s[1]\n";
   77 CDF::toEncodeTT2000(\@newtt2000s, 4, \@strs);
   78 print "0: $strs[0]\n";
   79 print "1: $strs[1]\n"; 
   80 
   81 print "\nTesting EPOCH16.....\n";
   82 my @ep16;
   83 my $epoch16;
   84 $epoch16 = CDF::computeEPOCH16 ($year, $month, $day, $hour, $minute,  
   85                                 $second, $msec, 234, 567, 000, \@ep16);
   86 print "$ep16[0] + $ep16[1] \n";
   87 CDF::toEncodeEPOCH16(\@ep16, 4, $str);
   88 print "epoch16=$str\n";
   89 
   90 CDF::EPOCH16toUnixTime (\@ep16, \$unixTime);
   91 print  "unixtime=$unixTime\n";
   92 my @ep16o;
   93 CDF::UnixTimetoEPOCH16 ($unixTime, \@ep16o);
   94 print  "encoding $ep16o[0] $ep16o[1]\n";
   95 CDF::toEncodeEPOCH16(\@ep16o, 4, \$str);
   96 print "$str\n";
   97 
   98   exit;
   99