ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-DVB/DVB.pm
(Generate patch)

Comparing Linux-DVB/DVB.pm (file contents):
Revision 1.8 by root, Tue Apr 12 00:54:57 2005 UTC vs.
Revision 1.9 by root, Tue Apr 12 01:03:25 2005 UTC

30package Linux::DVB; 30package Linux::DVB;
31 31
32use Fcntl (); 32use Fcntl ();
33 33
34BEGIN { 34BEGIN {
35 $VERSION = '0.3'; 35 $VERSION = '0.4';
36 @ISA = qw(Exporter); 36 @ISA = qw(Exporter);
37 37
38 require XSLoader; 38 require XSLoader;
39 XSLoader::load __PACKAGE__, $VERSION; 39 XSLoader::load __PACKAGE__, $VERSION;
40 40
463Break down a "DVB time" (modified julian date + bcd encoded seconds) into 463Break down a "DVB time" (modified julian date + bcd encoded seconds) into
464it's components (non-C<_linear>) or into a seconds count (C<_linear> 464it's components (non-C<_linear>) or into a seconds count (C<_linear>
465variants) since the epoch (C<datetime_linear>) or the start of the day 465variants) since the epoch (C<datetime_linear>) or the start of the day
466(C<time_linear>). 466(C<time_linear>).
467 467
468The format of the returns value of the date and datetime functions is
469I<not> compatible with C<Time::Local>. Use the C<_linear> functions
470instead.
471
468Example: 472Example:
469 473
470 my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms 474 my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms
471 printf "Starts at %s\n", 475 printf "Starts at %s\n",
472 POSIX::strftime "%Y-%m-%d %H:%M:%S", 476 POSIX::strftime "%Y-%m-%d %H:%M:%S",
488sub date($) { 492sub date($) {
489 my ($mjd) = @_; 493 my ($mjd) = @_;
490 494
491 # Date is given in Modified Julian Date 495 # Date is given in Modified Julian Date
492 # Decoding routines taken from ANNEX C, ETSI EN 300 468 (DVB SI) 496 # Decoding routines taken from ANNEX C, ETSI EN 300 468 (DVB SI)
493 my $y_ = int ($mjd - 15078.2) / 365.25; 497 my $y_ = int (($mjd - 15078.2) / 365.25);
494 my $m_ = int (($mjd - 14956.1 - int ($y_ * 365.25)) / 30.6001); 498 my $m_ = int (($mjd - 14956.1 - int ($y_ * 365.25)) / 30.6001);
495 my $day = $mjd - 14956 - int ($y_ * 365.25) - int ($m_ * 30.6001); 499 my $day = $mjd - 14956 - int ($y_ * 365.25) - int ($m_ * 30.6001);
496 my $k = $m_ == 14 or $m_ == 15 ? 1 : 0; 500 my $k = $m_ == 14 or $m_ == 15 ? 1 : 0;
497 my $year = $y_ + $k + 1900; 501 my $year = $y_ + $k + 1900;
498 my $month = $m_ - 1 - $k * 12; 502 my $month = $m_ - 1 - $k * 12;
509 513
510 (($h * 60) + $m * 60) + $s 514 (($h * 60) + $m * 60) + $s
511} 515}
512 516
513sub datetime_linear($$) { 517sub datetime_linear($$) {
518 my ($sec, $min, $hour, $mday, $mon, $year) =
519 Linux::DVB::Decode::datetime $_[0], $_[1];
520
514 require Time::Local; 521 require Time::Local;
515 Time::Local::timegm (Linux::DVB::Decode::datetime $_[0], $_[1]) 522 Time::Local::timegm ($sec, $min, $hour, $mday, $mon - 1, $year)
516} 523}
517 524
518=back 525=back
519 526
520=head1 AUTHORS 527=head1 AUTHORS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines