MISR Toolkit  1.5.1
MtkUtcToTai.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkUtcToTai =
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  char utc_datetime[MTKd_DATETIME_LEN],
34  double *secTAI93 )
35 {
36  MTKt_status status_code; /* Return code of this function */
37  double jdTAI[2]; /* TAI Julian Date equivalent of input time */
38  double jdUTC[2]; /* UTC Julian Date equivalent of input time */
39  int scanCheck; /* checks the return value of sscanf call */
40  int year; /* year portion of date */
41  int month; /* month portion of date */
42  int day; /* day portion of date */
43  int hours; /* hours of the given date */
44  int minutes; /* minutes of the given date */
45  double seconds;
46 
47  if (secTAI93 == NULL)
49 
50  scanCheck = sscanf(utc_datetime,"%4d-%2d-%2dT%2d:%2d:%lfZ",
51  &year, &month, &day, &hours, &minutes, &seconds);
52  if (scanCheck != 6)
54 
55  if (month < 1 || month > 12)
57 
58  if (hours > 23)
60 
61  if (minutes > 59)
63 
64  if (seconds > 60.99999999)
65  {
67  }
68  else if (seconds >= 60.0 && (minutes != 59 || hours != 23))
70 
71  MtkUtcToUtcJd(utc_datetime, jdUTC);
72  MtkUtcJdToTaiJd(jdUTC, jdTAI);
73  MtkTaiJdToTai(jdTAI, secTAI93);
74 
75  return MTK_SUCCESS;
76 
77 ERROR_HANDLE:
78  return status_code;
79 }
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_status MtkUtcJdToTaiJd(double jdUTC[2], double jdTAI[2])
Convert UTC Julian date to TAI Julian date.
MTKt_status MtkUtcToUtcJd(char utc_datetime[MTKd_DATETIME_LEN], double jdUTC[2])
Convert UTC date to UTC Julian date.
Definition: MtkUtcToUtcJd.c:46
MTKt_status MtkUtcToTai(char utc_datetime[MTKd_DATETIME_LEN], double *secTAI93)
Convert UTC to TAI93.
Definition: MtkUtcToTai.c:32
MTKt_status MtkTaiJdToTai(double jdTAI[2], double *secTAI93)
Convert TAI Julian date to TAI93 time.
Definition: MtkTaiJdToTai.c:32
MTKt_status
Definition: MisrError.h:11
#define MTKd_DATETIME_LEN
Definition: MisrUtil.h:149

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