File Coverage

blib/lib/Time/TCB.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Time::TCB - Barycentric Coordinate Time
4              
5             =head1 SYNOPSIS
6              
7             use Time::TCB qw(tcb_instant_to_mjd tcb_mjd_to_instant);
8              
9             $mjd = tcb_instant_to_mjd($instant);
10             $instant = tcb_mjd_to_instant($mjd);
11              
12             =head1 DESCRIPTION
13              
14             Barycentric Coordinate Time (TCB) is a coordinate time scale representing
15             time in the Sol system. Specifically, it is the proper time experienced
16             by a distant clock comoving with the barycentre of the Sol system.
17              
18             This module represents instants on the TCB time scale as a scalar number
19             of SI seconds since an epoch. This is an appropriate form for all manner
20             of calculations. TCB is defined with a well-known point at TAI instant
21             1977-01-01T00:00:00.0 at the Terran geocentre. This point is assigned the
22             scalar value -460_080_000, putting the epoch at approximately the date
23             at which the resolution defining TCB was adopted by the International
24             Astronomical Union. This epoch is deliberately very different from
25             those used for Geocentric Coordinate Time (TCG) in L and for
26             Terrestrial Time (TT) in L, to avoid confusion between them.
27              
28             There is also a conventional way to represent TCB instants using day-based
29             notations associated with planetary rotation `time' scales. The `day'
30             of TCB is a nominal period of exactly 86400 SI seconds, which is slightly
31             shorter than an actual Terran day. The well-known point at TAI instant
32             1977-01-01T00:00:00.0 is assigned the label 1977-01-01T00:00:32.184
33             (MJD 43144.0003725). Because TCB is not connected to Terran rotation,
34             and so has no inherent concept of a day, it is somewhat misleading to
35             use such day-based notations. Conversion between this notation and
36             the linear count of seconds is supported by this module. The day-based
37             notations for TT, TCG, and TCB instants yield very similar values for
38             corresponding instants, so care must be taken to avoid confusion.
39              
40             =cut
41              
42             package Time::TCB;
43              
44 1     1   63601 { use 5.006; }
  1         3  
45 1     1   8 use warnings;
  1         2  
  1         40  
46 1     1   6 use strict;
  1         7  
  1         33  
47              
48 1     1   616 use Math::BigRat 0.13;
  1         76161  
  1         8  
49              
50             our $VERSION = "0.003";
51              
52 1     1   1623 use parent "Exporter";
  1         282  
  1         7  
53             our @EXPORT_OK = qw(tcb_instant_to_mjd tcb_mjd_to_instant);
54              
55             =head1 FUNCTIONS
56              
57             =over
58              
59             =item tcb_instant_to_mjd(INSTANT)
60              
61             Converts from a count of seconds to a Modified Julian Date in the manner
62             conventional for TCB. The MJD can be further converted to other forms of
63             day-based date using other modules. The input must be a C
64             object, and the result is the same type.
65              
66             =cut
67              
68 1     1   84 use constant TCB_EPOCH_MJD => Math::BigRat->new("48469.0003725");
  1         2  
  1         6  
69              
70             sub tcb_instant_to_mjd($) {
71 4     4 1 13330 my($instant) = @_;
72 4         17 return TCB_EPOCH_MJD + ($instant / 86400);
73             }
74              
75             =item tcb_mjd_to_instant(MJD)
76              
77             Converts from a Modified Julian Date, interpreted in the manner
78             conventional for TCB, to a count of seconds. The input must be a
79             C object, and the result is the same type.
80              
81             =cut
82              
83             sub tcb_mjd_to_instant($) {
84 4     4 1 8340 my($mjd) = @_;
85 4         18 return ($mjd - TCB_EPOCH_MJD) * 86400;
86             }
87              
88             =back
89              
90             =head1 SEE ALSO
91              
92             L,
93             L,
94             L
95              
96             =head1 AUTHOR
97              
98             Andrew Main (Zefram)
99              
100             =head1 COPYRIGHT
101              
102             Copyright (C) 2006, 2010, 2012, 2017
103             Andrew Main (Zefram)
104              
105             =head1 LICENSE
106              
107             This module is free software; you can redistribute it and/or modify it
108             under the same terms as Perl itself.
109              
110             =cut
111              
112             1;