MISR Toolkit  1.5.1
MtkTaiJdToUtcJd.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkTaiJdToUtcJd =
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 jdTAI[2],
34  double jdUTC[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] <= jdTAI[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  jdUTC[0] = jdTAI[0];
54  jdUTC[1] = jdTAI[1] - leapSecs / SECONDSperDAY;
55 
56  if (jdUTC[1] < 0.0)
57  {
58  jdUTC[0] -= 1.0;
59  jdUTC[1] += 1.0;
60  }
61 
62  if (jdUTC[1] >= 1.0)
63  {
64  jdUTC[0] += 1.0;
65  jdUTC[1] -= 1.0;
66  }
67 
68  return MTK_SUCCESS;
69 
70 ERROR_HANDLE:
71  return status_code;
72 }
#define SECONDSperDAY
Definition: MisrUtil.h:145
MTKt_status MtkTaiJdToUtcJd(double jdTAI[2], double jdUTC[2])
Convert TAI Julian date to UTC Julian date.
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
#define LEAP_SECONDS
Definition: MisrUtil.h:152
MTKt_status
Definition: MisrError.h:11

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