TCG/Realisation.pm

filter: Statementstmt 50.0% 14 / 28 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 4 / 10 Podpod 100% 6 / 6 totaltotal 50.0% 24 / 48 CC 3 SCAR 11.0
CC
3
Cov
44%
to_realisation
6.0
from_realisation
6.0
new
2.0
CRAP 3.0
↑ Summary TCG.pm »
1 =head1 NAME
2  
3 Time::TCG::Realisation - realisation of Geocentric Coordinate Time
4  
5 =head1 SYNOPSIS
6  
7 use Time::TCG::Realisation;
8  
9 $rln = Time::TCG::Realisation->new($tt_rln);
10 $tt_rln = $rln->tcg_tt_realisation;
11  
12 $tcg_tai_instant = $rln->to_tcg_tai($tcg_k_instant);
13 $tcg_k_instant = $rln->from_tcg_tai($tcg_tai_instant);
14  
15 $rln1_instant = $rln0->to_realisation($rln1, $rln0_instant);
16 $rln0_instant = $rln0->from_realisation($rln1, $rln1_instant);
17  
18 =head1 DESCRIPTION
19  
20 Geocentric Coordinate Time (TCG) is a platonic time scale, consisting of the
21 time axis of a relativistic reference frame comoving with the Terran
22 geocentre. It is not directly accessible for practical use. Instead,
23 it must be realised by the use of atomic clocks and other equipment.
24 A realisation is inevitably imperfect, only approximating the true TCG.
25 Consequently there are many realisations, with differing degrees of
26 accuracy and accessibility.
27  
28 An object of this class represents a realisation of TCG. Because TCG
29 has a precisely-defined relationship to Terrestrial Time (TT), anything
30 that realises one of these scales implicitly also realises the other.
31 Because of this every realisation of TCG is implemented using an
32 underlying realisation of TT.
33  
34 In this interface, instants on the TCG scale are represented as a scalar
35 number of seconds since the TCG epoch, as described in L<Time::TCG>.
36 All such numbers are represented as C<Math::BigRat> objects.
37  
38 =cut
39  
40 package Time::TCG::Realisation;
41  
42 1 ▶{ use 5.006; }
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 1 ▶use Time::TCG 0.002 qw(tcg_to_tt tt_to_tcg);
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 1 our $VERSION = "0.002";
49  
50 =head1 CONSTRUCTOR
51  
52 =over
53  
54 =item Time::TCG::Realisation->new(TT_REALISATION)
55  
56 Creates and returns a new TCG realisation object based on the provided
57 TT realisation object. The TT realisation object must be of type
58 C<Time::TT::Realisation>.
59  
60 =cut
61  
62 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
63 0 my($class, $tt_rln) = @_;
64 0 return bless(\$tt_rln, $class);
65 }
66  
67 =back
68  
69 =head1 METHODS
70  
71 =over
72  
73 =item $rln->tcg_tt_realisation
74  
75 Returns the TT realisation object underlying this TCG realisation.
76  
77 =cut
78  
79 0 ▶sub tcg_tt_realisation { ${$_[0]} }
Subroutine tcg_tt_realisation: not called CC=1 SCAR=6.9
Pod documented
80  
81 =item $rln->to_tcg_tai(INSTANT)
82  
83 Takes an instant expressed on the time scale represented by this object,
84 and converts it to an instant on the TCG(TAI) scale. The input must be
85 a C<Math::BigRat> object, and the result is the same type.
86  
87 =cut
88  
89 0 ▶sub to_tcg_tai {
Subroutine to_tcg_tai: not called CC=1 SCAR=6.9
Pod documented
90 0 my($self, $t) = @_;
91 0 return tt_to_tcg($self->tcg_tt_realisation->to_tai(tcg_to_tt($t)));
92 }
93  
94 =item $rln->from_tcg_tai(INSTANT)
95  
96 Takes an instant expressed on the TCG(TAI) scale, and converts it to an
97 instant on the time scale represented by this object. The input must
98 be a C<Math::BigRat> object, and the result is the same type.
99  
100 =cut
101  
102 0 ▶sub from_tcg_tai {
Subroutine from_tcg_tai: not called CC=1 SCAR=6.9
Pod documented
103 0 my($self, $t) = @_;
104 0 return tt_to_tcg($self->tcg_tt_realisation->from_tai(tcg_to_tt($t)));
105 }
106  
107 =item $rln->to_realisation(REALISATION, INSTANT)
108  
109 Takes an instant expressed on the time scale represented by this object,
110 and converts it to an instant on the time scale represented by the
111 REALISATION object (which must be another realisation of TCG). The input
112 must be a C<Math::BigRat> object, and the result is the same type.
113  
114 =cut
115  
116 0 ▶sub to_realisation {
Subroutine to_realisation: not called CC=2 SCAR=17.9
Pod documented
117 0 my($self, $rln, $t) = @_;
118 0 ▶ return $t if $rln == $self;
Branch: 1 branch
BranchTrueFalseTotal
if $rln == $self 0 0 0
119 0 return tt_to_tcg($self->tcg_tt_realisation
120 ->to_realisation($rln->tcg_tt_realisation,
121 tcg_to_tt($t)));
122 }
123  
124 =item $rln->from_realisation(REALISATION, INSTANT)
125  
126 Takes an instant expressed on the time scale represented by the
127 REALISATION object (which must be another realisation of TCG), and
128 converts it to an instant on the time scale represented by this object.
129 The input must be a C<Math::BigRat> object, and the result is the
130 same type.
131  
132 =cut
133  
134 0 ▶sub from_realisation {
Subroutine from_realisation: not called CC=2 SCAR=17.9
Pod documented
135 0 my($self, $rln, $t) = @_;
136 0 ▶ return $t if $rln == $self;
Branch: 1 branch
BranchTrueFalseTotal
if $rln == $self 0 0 0
137 0 return tt_to_tcg($self->tcg_tt_realisation
138 ->from_realisation($rln->tcg_tt_realisation,
139 tcg_to_tt($t)));
140 }
141  
142 =back
143  
144 =head1 SEE ALSO
145  
146 L<Time::TCG>,
147 L<Time::TT::Realisation>
148  
149 =head1 AUTHOR
150  
151 Andrew Main (Zefram) <zefram@fysh.org>
152  
153 =head1 COPYRIGHT
154  
155 Copyright (C) 2006, 2010, 2012 Andrew Main (Zefram) <zefram@fysh.org>
156  
157 =head1 LICENSE
158  
159 This module is free software; you can redistribute it and/or modify it
160 under the same terms as Perl itself.
161  
162 =cut
163  
164 1 1;
↑ Summary TCG.pm »