Thursday, September 24, 2009

segwrapper.pm の脱 inverse_julian_day 化

player.pl 差し替え版から呼び出される segwrapper.pm はTime-modules の inverse_julian_day を使うため、ActivePerlで使う場合にややこしい手続きが必要らしい。
OneSeg24ForLinux の rec.pl の一部を移植して脱 inverse_julian_day できるはず。

*** segwrapper.pm.orig Wed Sep 23 00:00:00 2009
--- segwrapper.pm Wed Sep 23 00:00:01 2009
***************
*** 4,10 ****

use strict;
use Time::Local;
! use Time::JulianDay;
use Fcntl;


--- 4,10 ----

use strict;
use Time::Local;
! #use Time::JulianDay;
use Fcntl;


***************
*** 37,43 ****
my $totcode = shift;
my($mjd,$y,$m,$d,$h,$n,$s,$ch,$cn,$cs);
($mjd,$ch,$cn,$cs) = unpack("nCCC",$totcode);
! ($y,$m,$d) = inverse_julian_day($mjd+2400000.5+1); # @@@ +1?
$h = (($ch >> 4) & 0x0F) * 10 + ($ch & 0x0F);
$n = (($cn >> 4) & 0x0F) * 10 + ($cn & 0x0F);
$s = (($cs >> 4) & 0x0F) * 10 + ($cs & 0x0F);
--- 37,54 ----
my $totcode = shift;
my($mjd,$y,$m,$d,$h,$n,$s,$ch,$cn,$cs);
($mjd,$ch,$cn,$cs) = unpack("nCCC",$totcode);
! # ($y,$m,$d) = inverse_julian_day($mjd+2400000.5+1); # @@@ +1?
!
! $y = int(($mjd - 15078.2) / 365.25);
! $m = int(($mjd - 14956.1 - int($y * 365.25)) / 30.6001);
! $d = int($mjd - 14956 - int($y * 365.25) - int($m * 30.6001));
! if (13 < $m) {
! $y = $y + 1;
! $m = $m - 12;
! }
! $y = $y + 1900;
! $m = $m - 1;
!
$h = (($ch >> 4) & 0x0F) * 10 + ($ch & 0x0F);
$n = (($cn >> 4) & 0x0F) * 10 + ($cn & 0x0F);
$s = (($cs >> 4) & 0x0F) * 10 + ($cs & 0x0F);

No comments: