Changeset 1223
- Timestamp:
- Jul 15, 2004, 9:02:13 AM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 7 added
- 3 edited
-
src/astro/psTime.c (added)
-
src/astro/psTime.h (modified) (4 diffs)
-
src/astronomy/Makefile (modified) (1 diff)
-
src/astronomy/psTime.c (added)
-
src/astronomy/psTime.h (modified) (4 diffs)
-
test/astronomy (added)
-
test/astronomy/Makefile (added)
-
test/astronomy/builddir (added)
-
test/astronomy/builddir/tst_psTime_01.d (added)
-
test/astronomy/tst_psTime_01.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psTime.h
r1211 r1223 1 1 /** @file psTime.h 2 2 * 3 * @brief Provides time and timing utilities for psLib. 3 * @brief Definitions for time, time utilities, and conversion functions for use with psLib astronomy 4 * functions. 4 5 * 5 * Time, time utilities, and conversion functions are defined for use with psLib astronomy functions. 6 * 7 * @ingroup Time 6 * A collection of functions are required by psLib to manipulate time data. These functions primarily consist 7 * of conversions between specific time formats. PSLib currently uses the UNIX timeval time system as the 8 * base upon which International Atomic Time (TAI) time is calculated. All time conversion functions within 9 * psLib, except those noted, are calculated in terms of TAI time, which is approxinmately 32 seconds faster 10 * than UTC/timeval. 8 11 * 9 12 * @author Ross Harman, MHPCC 10 13 * 11 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-07-1 3 01:04:37$14 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-07-15 19:02:13 $ 13 16 * 14 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 20 #ifndef PSTIME_H 18 21 #define PSTIME_H 22 23 #include <time.h> 24 #include <sys/types.h> 25 #include <sys/time.h> 26 27 #include "psType.h" 19 28 20 29 /// @addtogroup Time … … 25 34 /******************************************************************************/ 26 35 27 /** Struct containingpsTime.36 /** Definition of psTime. 28 37 * 29 * This struct defines current time in terms of seconds, nanoseconds, and attoseconds. 38 * The psTime struct is used by psLib to represent time values critical to astronomical calculations. This 39 * structure represents a time which is equivalent to TAI (International Atomic Time) and is measured in 40 * both seconds and microseconds. 30 41 */ 31 42 typedef struct 32 43 { 33 long tv_sec; /**< Seconds since epoch, Jan 1, 1970. */ 34 long tv_nsec; /**< Nanoseconds since last second. */ 35 long tv_asec; /**< Attoseconds since last nanosecond. */ 44 time_t tv_sec; /**< Seconds since epoch, Jan 1, 1970. */ 45 suseconds_t tv_usec; /**< Microseconds since last second. */ 36 46 } 37 47 psTime; … … 41 51 /*****************************************************************************/ 42 52 43 /** Get current UTCtime.53 /** Get current TAI time. 44 54 * 45 * Gets current UTC timespec time.55 * Gets current time from the system clock in correct TAI units. 46 56 * 47 * @return psTime *: Pointer to struct with current time.57 * @return psTime: Struct with current time. 48 58 */ 49 psTime * psGetTime(50 psTime *time /** Time to return or null for auto allocation. */59 psTime psTimeGetTime( 60 void /** No argument. */ 51 61 ); 52 62 53 /** Convert psTime to ISO time .63 /** Convert psTime to ISO time in TAI units. 54 64 * 55 * Converts psTime to a null terminated string in the form of: YYYY/MM/DD,HH:MM:SS.SSS. 65 * Converts psTime to a null terminated string in the form of: YYYY/MM/DD,HH:MM:SS.SSS. The result from this 66 * function is in TAI units. 56 67 * 57 * @return char*: Pointer null terminated array of chars .68 * @return char*: Pointer null terminated array of chars in ISO/TAI time. 58 69 */ 59 char* psTimeToISO Time(60 psTime *time/** Input time to be converted. */70 char* psTimeToISO( 71 psTime time /** Input time to be converted. */ 61 72 ); 62 73 63 74 /** Convert psTime to UTC time. 64 75 * 65 * Converts psTime to UTC time in double precision floating point notation. 76 * Converts psTime to UTC time in double precision floating point notation. The result from this function is 77 * not in TAI units, but that of UTC, which does not contain leapseconds. 66 78 * 67 79 * @return double: UTC time in floating point notation. 68 80 */ 69 double psTimeTo ISOTime(70 psTime *time /** Input time to be converted. */81 double psTimeToUTC( 82 psTime time /** Input time to be converted. */ 71 83 ); 72 84 85 /** Convert psTime to modified Julian date time. 86 * 87 * Converts psTime to modified Julian date (MJD) time. The result from this function is in TAI units. 88 * 89 * @return double: MJD/TAI time in floating point notation. 90 */ 91 double psTimeToMJD( 92 psTime time /** Input time to be converted. */ 93 ); 94 95 /** Convert psTime to Julian date time. 96 * 97 * Converts psTime to Julian date (JD) time. The result from this function is in TAI units. 98 * 99 * @return double: JD/TAI time in floating point notation. 100 */ 101 double psTimeToJD( 102 psTime time /** Input time to be converted. */ 103 ); 104 105 /** Convert psTime to timeval time. 106 * 107 * Converts psTime to timeval time. The result from this function is in TAI units. 108 * 109 * @return timeval: timeval/TAI time. 110 */ 111 struct timeval psTimeToTimeval( 112 psTime time /** Input time to be converted. */ 113 ); 114 115 /** Convert psTime to tm time. 116 * 117 * Converts psTime to tm time. The result from this function is in TAI units. 118 * 119 * @return tm: tm/TAI time. 120 */ 121 struct tm* psTimeToTM( 122 psTime time /** Input time to be converted. */ 123 ); 124 125 /** Convert ISO to psTime. 126 * 127 * Converts ISO time to psTime. The result from this function is in TAI units. 128 * 129 * @return psTime: time in TAI units. 130 */ 131 psTime psISOToTime(char *time); 132 133 /** Convert UTC to psTime. 134 * 135 * Converts UTC time to psTime. The result from this function is in TAI units. 136 * 137 * @return psTime: time in TAI units. 138 */ 139 psTime psUTCToTime(double time); 140 141 /** Convert MJD to psTime. 142 * 143 * Converts MJD time to psTime. The result from this function is in TAI units. 144 * 145 * @return psTime: time in TAI units. 146 */ 147 psTime psMJDToTime(double time); 148 149 /** Convert JD to psTime. 150 * 151 * Converts JD time to psTime. The result from this function is in TAI units. 152 * 153 * @return psTime: time in TAI units. 154 */ 155 psTime psJDToTime(double time); 156 157 /** Convert timeval to psTime. 158 * 159 * Converts timeval time to psTime. The result from this function is in TAI units. 160 * 161 * @return psTime: time in TAI units. 162 */ 163 psTime psTimevalToTime(struct timeval *time); 164 165 /** Convert tm time to psTime. 166 * 167 * Converts tm time to psTime. The result from this function is in TAI units. 168 * 169 * @return psTime: time in TAI units. 170 */ 171 psTime psTMToTime(struct tm *time); 73 172 /// @} 74 173 -
trunk/psLib/src/astronomy/Makefile
r1209 r1223 7 7 CFLAGS := $(CFLAGS_RELOC) -I. -I../sysUtils -I../collections -I.. 8 8 9 SRC_OBJS = 9 SRC_OBJS = psTime.o 10 10 11 11 all: $(TARGET_STATIC) -
trunk/psLib/src/astronomy/psTime.h
r1211 r1223 1 1 /** @file psTime.h 2 2 * 3 * @brief Provides time and timing utilities for psLib. 3 * @brief Definitions for time, time utilities, and conversion functions for use with psLib astronomy 4 * functions. 4 5 * 5 * Time, time utilities, and conversion functions are defined for use with psLib astronomy functions. 6 * 7 * @ingroup Time 6 * A collection of functions are required by psLib to manipulate time data. These functions primarily consist 7 * of conversions between specific time formats. PSLib currently uses the UNIX timeval time system as the 8 * base upon which International Atomic Time (TAI) time is calculated. All time conversion functions within 9 * psLib, except those noted, are calculated in terms of TAI time, which is approxinmately 32 seconds faster 10 * than UTC/timeval. 8 11 * 9 12 * @author Ross Harman, MHPCC 10 13 * 11 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-07-1 3 01:04:37$14 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-07-15 19:02:13 $ 13 16 * 14 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 20 #ifndef PSTIME_H 18 21 #define PSTIME_H 22 23 #include <time.h> 24 #include <sys/types.h> 25 #include <sys/time.h> 26 27 #include "psType.h" 19 28 20 29 /// @addtogroup Time … … 25 34 /******************************************************************************/ 26 35 27 /** Struct containingpsTime.36 /** Definition of psTime. 28 37 * 29 * This struct defines current time in terms of seconds, nanoseconds, and attoseconds. 38 * The psTime struct is used by psLib to represent time values critical to astronomical calculations. This 39 * structure represents a time which is equivalent to TAI (International Atomic Time) and is measured in 40 * both seconds and microseconds. 30 41 */ 31 42 typedef struct 32 43 { 33 long tv_sec; /**< Seconds since epoch, Jan 1, 1970. */ 34 long tv_nsec; /**< Nanoseconds since last second. */ 35 long tv_asec; /**< Attoseconds since last nanosecond. */ 44 time_t tv_sec; /**< Seconds since epoch, Jan 1, 1970. */ 45 suseconds_t tv_usec; /**< Microseconds since last second. */ 36 46 } 37 47 psTime; … … 41 51 /*****************************************************************************/ 42 52 43 /** Get current UTCtime.53 /** Get current TAI time. 44 54 * 45 * Gets current UTC timespec time.55 * Gets current time from the system clock in correct TAI units. 46 56 * 47 * @return psTime *: Pointer to struct with current time.57 * @return psTime: Struct with current time. 48 58 */ 49 psTime * psGetTime(50 psTime *time /** Time to return or null for auto allocation. */59 psTime psTimeGetTime( 60 void /** No argument. */ 51 61 ); 52 62 53 /** Convert psTime to ISO time .63 /** Convert psTime to ISO time in TAI units. 54 64 * 55 * Converts psTime to a null terminated string in the form of: YYYY/MM/DD,HH:MM:SS.SSS. 65 * Converts psTime to a null terminated string in the form of: YYYY/MM/DD,HH:MM:SS.SSS. The result from this 66 * function is in TAI units. 56 67 * 57 * @return char*: Pointer null terminated array of chars .68 * @return char*: Pointer null terminated array of chars in ISO/TAI time. 58 69 */ 59 char* psTimeToISO Time(60 psTime *time/** Input time to be converted. */70 char* psTimeToISO( 71 psTime time /** Input time to be converted. */ 61 72 ); 62 73 63 74 /** Convert psTime to UTC time. 64 75 * 65 * Converts psTime to UTC time in double precision floating point notation. 76 * Converts psTime to UTC time in double precision floating point notation. The result from this function is 77 * not in TAI units, but that of UTC, which does not contain leapseconds. 66 78 * 67 79 * @return double: UTC time in floating point notation. 68 80 */ 69 double psTimeTo ISOTime(70 psTime *time /** Input time to be converted. */81 double psTimeToUTC( 82 psTime time /** Input time to be converted. */ 71 83 ); 72 84 85 /** Convert psTime to modified Julian date time. 86 * 87 * Converts psTime to modified Julian date (MJD) time. The result from this function is in TAI units. 88 * 89 * @return double: MJD/TAI time in floating point notation. 90 */ 91 double psTimeToMJD( 92 psTime time /** Input time to be converted. */ 93 ); 94 95 /** Convert psTime to Julian date time. 96 * 97 * Converts psTime to Julian date (JD) time. The result from this function is in TAI units. 98 * 99 * @return double: JD/TAI time in floating point notation. 100 */ 101 double psTimeToJD( 102 psTime time /** Input time to be converted. */ 103 ); 104 105 /** Convert psTime to timeval time. 106 * 107 * Converts psTime to timeval time. The result from this function is in TAI units. 108 * 109 * @return timeval: timeval/TAI time. 110 */ 111 struct timeval psTimeToTimeval( 112 psTime time /** Input time to be converted. */ 113 ); 114 115 /** Convert psTime to tm time. 116 * 117 * Converts psTime to tm time. The result from this function is in TAI units. 118 * 119 * @return tm: tm/TAI time. 120 */ 121 struct tm* psTimeToTM( 122 psTime time /** Input time to be converted. */ 123 ); 124 125 /** Convert ISO to psTime. 126 * 127 * Converts ISO time to psTime. The result from this function is in TAI units. 128 * 129 * @return psTime: time in TAI units. 130 */ 131 psTime psISOToTime(char *time); 132 133 /** Convert UTC to psTime. 134 * 135 * Converts UTC time to psTime. The result from this function is in TAI units. 136 * 137 * @return psTime: time in TAI units. 138 */ 139 psTime psUTCToTime(double time); 140 141 /** Convert MJD to psTime. 142 * 143 * Converts MJD time to psTime. The result from this function is in TAI units. 144 * 145 * @return psTime: time in TAI units. 146 */ 147 psTime psMJDToTime(double time); 148 149 /** Convert JD to psTime. 150 * 151 * Converts JD time to psTime. The result from this function is in TAI units. 152 * 153 * @return psTime: time in TAI units. 154 */ 155 psTime psJDToTime(double time); 156 157 /** Convert timeval to psTime. 158 * 159 * Converts timeval time to psTime. The result from this function is in TAI units. 160 * 161 * @return psTime: time in TAI units. 162 */ 163 psTime psTimevalToTime(struct timeval *time); 164 165 /** Convert tm time to psTime. 166 * 167 * Converts tm time to psTime. The result from this function is in TAI units. 168 * 169 * @return psTime: time in TAI units. 170 */ 171 psTime psTMToTime(struct tm *time); 73 172 /// @} 74 173
Note:
See TracChangeset
for help on using the changeset viewer.
