MISR Toolkit  1.5.1
MtkUtcJdToTaiJd.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkUtcJdToTaiJd =
4 = =
5 =============================================================================
6 
7  Jet Propulsion Laboratory
8  MISR
9  MISR Toolkit
10 
11  Copyright 2006, California Institute of Technology.
12  ALL RIGHTS RESERVED.
13  U.S. Government Sponsorship acknowledged.
14 
15 ============================================================================*/
16 
17 #include "MisrUtil.h"
18 #include "MisrError.h"
19 
33  double jdUTC[2],
34  double jdTAI[2] )
35 {
36  MTKt_status status_code; /* Return code of this function */
37  double leap_seconds[][2] = LEAP_SECONDS;
38  double leapSecs = 0.0;
39  int i;
40 
41  /* Find leap seconds */
42  for (i = sizeof(leap_seconds) / sizeof(*leap_seconds) - 1; i >= 0; --i)
43  if (leap_seconds[i][0] <= jdUTC[0])
44  {
45  leapSecs = leap_seconds[i][1];
46  break;
47  }
48 
49  /* Make sure time isn't before leap second range. */
50  if (i == -1)
52 
53  jdTAI[0] = jdUTC[0];
54  jdTAI[1] = jdUTC[1] + ((leapSecs) / SECONDSperDAY);
55 
56  if (jdTAI[1] >= 1.0)
57  {
58  jdTAI[0] += 1.0;
59  jdTAI[1] -= 1.0;
60  }
61 
62  return MTK_SUCCESS;
63 
64 ERROR_HANDLE:
65  return status_code;
66 }
#define SECONDSperDAY
Definition: MisrUtil.h:145
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
#define LEAP_SECONDS
Definition: MisrUtil.h:152
MTKt_status MtkUtcJdToTaiJd(double jdUTC[2], double jdTAI[2])
Convert UTC Julian date to TAI Julian date.
MTKt_status
Definition: MisrError.h:11

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:52