| 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<Time::TCG> and for | ||
| 26 | Terrestrial Time (TT) in L<Time::TT>, 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 | 2 | ▶ | { use 5.006; } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 45 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 46 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 47 | |||
| 48 | 2 | ▶ | use Math::BigRat 0.13; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 49 | |||
| 50 | 2 | our $VERSION = "0.003"; | |
| 51 | |||
| 52 | 2 | ▶ | use parent "Exporter"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 53 | 2 | 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<Math::BigRat> | ||
| 64 | object, and the result is the same type. | ||
| 65 | |||
| 66 | =cut | ||
| 67 | |||
| 68 | 2 | ▶ | use constant TCB_EPOCH_MJD => Math::BigRat->new("48469.0003725"); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 69 | |||
| 70 | 4 | ▶ | sub tcb_instant_to_mjd($) { |
|
Subroutine
tcb_instant_to_mjd: called CC=1 SCAR=0.0
Pod
documented
| |||
| 71 | 4 | my($instant) = @_; | |
| 72 | 4 | 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<Math::BigRat> object, and the result is the same type. | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | 4 | ▶ | sub tcb_mjd_to_instant($) { |
|
Subroutine
tcb_mjd_to_instant: called CC=1 SCAR=0.0
Pod
documented
| |||
| 84 | 4 | my($mjd) = @_; | |
| 85 | 4 | return ($mjd - TCB_EPOCH_MJD) * 86400; | |
| 86 | } | ||
| 87 | |||
| 88 | =back | ||
| 89 | |||
| 90 | =head1 SEE ALSO | ||
| 91 | |||
| 92 | L<Date::JD>, | ||
| 93 | L<Time::TCG>, | ||
| 94 | L<Time::TT> | ||
| 95 | |||
| 96 | =head1 AUTHOR | ||
| 97 | |||
| 98 | Andrew Main (Zefram) <zefram@fysh.org> | ||
| 99 | |||
| 100 | =head1 COPYRIGHT | ||
| 101 | |||
| 102 | Copyright (C) 2006, 2010, 2012, 2017 | ||
| 103 | Andrew Main (Zefram) <zefram@fysh.org> | ||
| 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 | 2 | 1; | |