| 1 | =head1 NAME | ||
| 2 | |||
| 3 | Time::TCG - Geocentric Coordinate Time and realisations | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | use Time::TCG qw(tcg_instant_to_mjd tcg_mjd_to_instant); | ||
| 8 | |||
| 9 | $mjd = tcg_instant_to_mjd($instant); | ||
| 10 | $instant = tcg_mjd_to_instant($mjd); | ||
| 11 | |||
| 12 | use Time::TCG qw(tcg_to_tt tt_to_tcg); | ||
| 13 | |||
| 14 | $tt_instant = tcg_to_tt($tcg_instant); | ||
| 15 | $tcg_instant = tt_to_tcg($tt_instant); | ||
| 16 | |||
| 17 | use Time::TCG qw(tcg_realisation); | ||
| 18 | |||
| 19 | $rln = tcg_realisation("bipm05"); | ||
| 20 | $instant = $rln->from_tcg_tai($tcg_tai_instant); | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | Geocentric Coordinate Time (TCG) is a coordinate time scale representing | ||
| 25 | time in the Terran system. Specifically, it is the proper time | ||
| 26 | experienced by a distant clock comoving with the geocentre. It is | ||
| 27 | linearly related to Terrestrial Time (TT), which is the proper time scale | ||
| 28 | underlying timekeeping on the Terran surface. TT is formally defined | ||
| 29 | in terms of TCG: TT ticks exactly 0.999_999_999_303_070_986_6 seconds | ||
| 30 | for each second of TCG. | ||
| 31 | |||
| 32 | This module represents instants on the TCG and TT time scales as scalar | ||
| 33 | numbers of SI seconds since an epoch. This is an appropriate form for | ||
| 34 | all manner of calculations. Both scales are defined with a well-known | ||
| 35 | point at TAI instant 1977-01-01T00:00:00.0. This point is used as the | ||
| 36 | epoch for TCG, having the scalar value zero. The same instant on the | ||
| 37 | TT scale is assigned the scalar value 599_616_000 exactly, corresponding | ||
| 38 | to an epoch near the TAI epoch 1958-01-01T00:00:00.0. This matches the | ||
| 39 | convention used by C<Time::TT> for instants on the TT scale. The use | ||
| 40 | of very different epochs for the two scales avoids confusion between them. | ||
| 41 | |||
| 42 | There is also a conventional way to represent TCG instants using day-based | ||
| 43 | notations associated with planetary rotation `time' scales. The `day' | ||
| 44 | of TCG is a nominal period of exactly 86400 SI seconds, which is slightly | ||
| 45 | shorter than an actual Terran day. The well-known point at TAI instant | ||
| 46 | 1977-01-01T00:00:00.0 is assigned the label 1977-01-01T00:00:32.184 | ||
| 47 | (MJD 43144.0003725). Because TCG is not connected to Terran rotation, | ||
| 48 | and so has no inherent concept of a day, it is somewhat misleading to use | ||
| 49 | such day-based notations. Conversion between this notation and the linear | ||
| 50 | count of seconds is supported by this module. The day-based notations for | ||
| 51 | TT and TCG instants yield very similar values for corresponding instants, | ||
| 52 | so care must be taken to avoid confusion. | ||
| 53 | |||
| 54 | Because TCG is a theoretical time scale, not directly accessible for | ||
| 55 | practical use, it must be realised using atomic clocks. In fact, it is TT | ||
| 56 | that is directly so realised, but the linear relationship between TT and | ||
| 57 | TCG means that any realisation of TT is effectively also realising TCG. | ||
| 58 | This module supports conversion of times between different realisations of | ||
| 59 | TCG, by making use of the facility in C<Time::TT> for realisations of TT. | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | package Time::TCG; | ||
| 64 | |||
| 65 | 3 | ▶ | { use 5.006; } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 66 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 67 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 68 | |||
| 69 | 3 | ▶ | use Math::BigRat 0.13; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 70 | |||
| 71 | 3 | our $VERSION = "0.002"; | |
| 72 | |||
| 73 | 3 | ▶ | use parent "Exporter"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 74 | 3 | our @EXPORT_OK = qw( | |
| 75 | tcg_instant_to_mjd tcg_mjd_to_instant | ||
| 76 | tcg_to_tt tt_to_tcg | ||
| 77 | tcg_realisation | ||
| 78 | ); | ||
| 79 | |||
| 80 | =head1 FUNCTIONS | ||
| 81 | |||
| 82 | =over | ||
| 83 | |||
| 84 | =item tcg_instant_to_mjd(INSTANT) | ||
| 85 | |||
| 86 | Converts from a count of seconds to a Modified Julian Date in the manner | ||
| 87 | conventional for TCG. The MJD can be further converted to other forms of | ||
| 88 | day-based date using other modules. The input must be a C<Math::BigRat> | ||
| 89 | object, and the result is the same type. | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | 3 | ▶ | use constant TCG_EPOCH_MJD => Math::BigRat->new("43144.0003725"); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 94 | |||
| 95 | 4 | ▶ | sub tcg_instant_to_mjd($) { |
|
Subroutine
tcg_instant_to_mjd: called CC=1 SCAR=0.0
Pod
documented
| |||
| 96 | 4 | my($instant) = @_; | |
| 97 | 4 | return TCG_EPOCH_MJD + ($instant / 86400); | |
| 98 | } | ||
| 99 | |||
| 100 | =item tcg_mjd_to_instant(MJD) | ||
| 101 | |||
| 102 | Converts from a Modified Julian Date, interpreted in the manner | ||
| 103 | conventional for TCG, to a count of seconds. The input must be a | ||
| 104 | C<Math::BigRat> object, and the result is the same type. | ||
| 105 | |||
| 106 | =cut | ||
| 107 | |||
| 108 | 4 | ▶ | sub tcg_mjd_to_instant($) { |
|
Subroutine
tcg_mjd_to_instant: called CC=1 SCAR=0.0
Pod
documented
| |||
| 109 | 4 | my($mjd) = @_; | |
| 110 | 4 | return ($mjd - TCG_EPOCH_MJD) * 86400; | |
| 111 | } | ||
| 112 | |||
| 113 | =item tcg_to_tt(TCG_INSTANT) | ||
| 114 | |||
| 115 | Converts from a TCG instant (as a count of seconds from the TCG epoch) to | ||
| 116 | the corresponding TT instant (as a count of seconds from the TT epoch). | ||
| 117 | The input must be a C<Math::BigRat> object, and the result is the | ||
| 118 | same type. | ||
| 119 | |||
| 120 | =cut | ||
| 121 | |||
| 122 | 3 | ▶ | use constant TCG_EPOCH_TT => Math::BigRat->new(599616000); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 123 | 3 | ▶ | use constant TT_TICK_RATE => Math::BigRat->new("0.9999999993030709866"); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 124 | |||
| 125 | 3 | ▶ | sub tcg_to_tt($) { |
|
Subroutine
tcg_to_tt: called CC=1 SCAR=0.0
Pod
documented
| |||
| 126 | 3 | my($tcg) = @_; | |
| 127 | 3 | return TCG_EPOCH_TT + TT_TICK_RATE * $tcg; | |
| 128 | } | ||
| 129 | |||
| 130 | =item tt_to_tcg(TT_INSTANT) | ||
| 131 | |||
| 132 | Converts from a TT instant (as a count of seconds from the TT epoch) | ||
| 133 | to the corresponding TCG instant (as a count of seconds from the TCG | ||
| 134 | epoch). The input must be a C<Math::BigRat> object, and the result is | ||
| 135 | the same type. | ||
| 136 | |||
| 137 | =cut | ||
| 138 | |||
| 139 | 3 | ▶ | sub tt_to_tcg($) { |
|
Subroutine
tt_to_tcg: called CC=1 SCAR=0.0
Pod
documented
| |||
| 140 | 3 | my($tt) = @_; | |
| 141 | 3 | return ($tt - TCG_EPOCH_TT) / TT_TICK_RATE; | |
| 142 | } | ||
| 143 | |||
| 144 | =item tcg_realisation(NAME) | ||
| 145 | |||
| 146 | Looks up and returns an object representing a named realisation of TCG. | ||
| 147 | The object returned is of the class C<Time::TCG::Realisation>; see the | ||
| 148 | documentation of that class for its interface. Each TCG realisation | ||
| 149 | corresponds precisely to a realisation of TT. The realisation names | ||
| 150 | that are understood are exactly the same as those understood by | ||
| 151 | C<tt_realisation> in L<Time::TT>. | ||
| 152 | |||
| 153 | The C<Time::TT> module is required in order to do this. | ||
| 154 | |||
| 155 | =cut | ||
| 156 | |||
| 157 | 0 | ▶ | sub tcg_realisation($) { |
|
Subroutine
tcg_realisation: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 158 | 0 | my($name) = @_; | |
| 159 | 0 | require Time::TT; | |
| 160 | 0 | require Time::TCG::Realisation; | |
| 161 | 0 | return Time::TCG::Realisation->new(Time::TT::tt_realisation($name)); | |
| 162 | } | ||
| 163 | |||
| 164 | =back | ||
| 165 | |||
| 166 | =head1 SEE ALSO | ||
| 167 | |||
| 168 | L<Date::JD>, | ||
| 169 | L<Time::TCB>, | ||
| 170 | L<Time::TCG::Realisation>, | ||
| 171 | L<Time::TT> | ||
| 172 | |||
| 173 | =head1 AUTHOR | ||
| 174 | |||
| 175 | Andrew Main (Zefram) <zefram@fysh.org> | ||
| 176 | |||
| 177 | =head1 COPYRIGHT | ||
| 178 | |||
| 179 | Copyright (C) 2006, 2010, 2012 Andrew Main (Zefram) <zefram@fysh.org> | ||
| 180 | |||
| 181 | =head1 LICENSE | ||
| 182 | |||
| 183 | This module is free software; you can redistribute it and/or modify it | ||
| 184 | under the same terms as Perl itself. | ||
| 185 | |||
| 186 | =cut | ||
| 187 | |||
| 188 | 3 | 1; | |