source: branches/FACT++_part_filenames/erfa/src/utcut1.c@ 18796

Last change on this file since 18796 was 18711, checked in by tbretz, 8 years ago
Updated to ERFA 1.3.0 (no relevant code change except the leap second at the beginning of 2017)
File size: 5.9 KB
Line 
1#include "erfa.h"
2
3int eraUtcut1(double utc1, double utc2, double dut1,
4 double *ut11, double *ut12)
5/*
6** - - - - - - - - - -
7** e r a U t c u t 1
8** - - - - - - - - - -
9**
10** Time scale transformation: Coordinated Universal Time, UTC, to
11** Universal Time, UT1.
12**
13** Given:
14** utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 1-4)
15** dut1 double Delta UT1 = UT1-UTC in seconds (Note 5)
16**
17** Returned:
18** ut11,ut12 double UT1 as a 2-part Julian Date (Note 6)
19**
20** Returned (function value):
21** int status: +1 = dubious year (Note 3)
22** 0 = OK
23** -1 = unacceptable date
24**
25** Notes:
26**
27** 1) utc1+utc2 is quasi Julian Date (see Note 2), apportioned in any
28** convenient way between the two arguments, for example where utc1
29** is the Julian Day Number and utc2 is the fraction of a day.
30**
31** 2) JD cannot unambiguously represent UTC during a leap second unless
32** special measures are taken. The convention in the present
33** function is that the JD day represents UTC days whether the
34** length is 86399, 86400 or 86401 SI seconds.
35**
36** 3) The warning status "dubious year" flags UTCs that predate the
37** introduction of the time scale or that are too far in the future
38** to be trusted. See eraDat for further details.
39**
40** 4) The function eraDtf2d converts from calendar date and time of
41** day into 2-part Julian Date, and in the case of UTC implements
42** the leap-second-ambiguity convention described above.
43**
44** 5) Delta UT1 can be obtained from tabulations provided by the
45** International Earth Rotation and Reference Systems Service.
46** It is the caller's responsibility to supply a dut1 argument
47** containing the UT1-UTC value that matches the given UTC.
48**
49** 6) The returned ut11,ut12 are such that their sum is the UT1 Julian
50** Date.
51**
52** References:
53**
54** McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
55** IERS Technical Note No. 32, BKG (2004)
56**
57** Explanatory Supplement to the Astronomical Almanac,
58** P. Kenneth Seidelmann (ed), University Science Books (1992)
59**
60** Called:
61** eraJd2cal JD to Gregorian calendar
62** eraDat delta(AT) = TAI-UTC
63** eraUtctai UTC to TAI
64** eraTaiut1 TAI to UT1
65**
66** Copyright (C) 2013-2016, NumFOCUS Foundation.
67** Derived, with permission, from the SOFA library. See notes at end of file.
68*/
69{
70 int iy, im, id, js, jw;
71 double w, dat, dta, tai1, tai2;
72
73
74/* Look up TAI-UTC. */
75 if ( eraJd2cal(utc1, utc2, &iy, &im, &id, &w) ) return -1;
76 js = eraDat ( iy, im, id, 0.0, &dat);
77 if ( js < 0 ) return -1;
78
79/* Form UT1-TAI. */
80 dta = dut1 - dat;
81
82/* UTC to TAI to UT1. */
83 jw = eraUtctai(utc1, utc2, &tai1, &tai2);
84 if ( jw < 0 ) {
85 return -1;
86 } else if ( jw > 0 ) {
87 js = jw;
88 }
89 if ( eraTaiut1(tai1, tai2, dta, ut11, ut12) ) return -1;
90
91/* Status. */
92 return js;
93
94}
95/*----------------------------------------------------------------------
96**
97**
98** Copyright (C) 2013-2016, NumFOCUS Foundation.
99** All rights reserved.
100**
101** This library is derived, with permission, from the International
102** Astronomical Union's "Standards of Fundamental Astronomy" library,
103** available from http://www.iausofa.org.
104**
105** The ERFA version is intended to retain identical functionality to
106** the SOFA library, but made distinct through different function and
107** file names, as set out in the SOFA license conditions. The SOFA
108** original has a role as a reference standard for the IAU and IERS,
109** and consequently redistribution is permitted only in its unaltered
110** state. The ERFA version is not subject to this restriction and
111** therefore can be included in distributions which do not support the
112** concept of "read only" software.
113**
114** Although the intent is to replicate the SOFA API (other than
115** replacement of prefix names) and results (with the exception of
116** bugs; any that are discovered will be fixed), SOFA is not
117** responsible for any errors found in this version of the library.
118**
119** If you wish to acknowledge the SOFA heritage, please acknowledge
120** that you are using a library derived from SOFA, rather than SOFA
121** itself.
122**
123**
124** TERMS AND CONDITIONS
125**
126** Redistribution and use in source and binary forms, with or without
127** modification, are permitted provided that the following conditions
128** are met:
129**
130** 1 Redistributions of source code must retain the above copyright
131** notice, this list of conditions and the following disclaimer.
132**
133** 2 Redistributions in binary form must reproduce the above copyright
134** notice, this list of conditions and the following disclaimer in
135** the documentation and/or other materials provided with the
136** distribution.
137**
138** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
139** the International Astronomical Union nor the names of its
140** contributors may be used to endorse or promote products derived
141** from this software without specific prior written permission.
142**
143** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
144** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
145** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
146** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
147** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
148** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
149** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
150** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
151** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
152** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
153** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
154** POSSIBILITY OF SUCH DAMAGE.
155**
156*/
Note: See TracBrowser for help on using the repository browser.