Changeset 1615
- Timestamp:
- Aug 24, 2004, 3:38:48 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 4 edited
-
src/astro/psCoord.c (modified) (4 diffs)
-
src/astronomy/psCoord.c (modified) (4 diffs)
-
test/astronomy/tst_psTime_01.c (modified) (9 diffs)
-
test/astronomy/tst_psTime_02.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.c
r1532 r1615 3 3 * @brief Contains basic coordinate transformation definitions and operations 4 4 * 5 * This file defines the basic types for astronomical coordinate 5 * This file defines the basic types for astronomical coordinate 6 6 * transformation 7 7 * … … 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 13 23:43:29$12 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-25 01:38:30 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 196 196 psSphereTransform* psSphereTransformICRStoEcliptic(psTime time) 197 197 { 198 struct tm *tmTime = psTimeToTM( time);198 struct tm *tmTime = psTimeToTM(&time); 199 199 double year = (double)(1900 + tmTime->tm_year); 200 200 double T = year / 100.0; … … 208 208 psSphereTransform* psSphereTransformEcliptictoICRS(psTime time) 209 209 { 210 struct tm *tmTime = psTimeToTM( time);210 struct tm *tmTime = psTimeToTM(&time); 211 211 double year = (double)(1900 + tmTime->tm_year); 212 212 double T = year / 100.0; -
trunk/psLib/src/astronomy/psCoord.c
r1532 r1615 3 3 * @brief Contains basic coordinate transformation definitions and operations 4 4 * 5 * This file defines the basic types for astronomical coordinate 5 * This file defines the basic types for astronomical coordinate 6 6 * transformation 7 7 * … … 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 13 23:43:29$12 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-25 01:38:30 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 196 196 psSphereTransform* psSphereTransformICRStoEcliptic(psTime time) 197 197 { 198 struct tm *tmTime = psTimeToTM( time);198 struct tm *tmTime = psTimeToTM(&time); 199 199 double year = (double)(1900 + tmTime->tm_year); 200 200 double T = year / 100.0; … … 208 208 psSphereTransform* psSphereTransformEcliptictoICRS(psTime time) 209 209 { 210 struct tm *tmTime = psTimeToTM( time);210 struct tm *tmTime = psTimeToTM(&time); 211 211 double year = (double)(1900 + tmTime->tm_year); 212 212 double T = year / 100.0; -
trunk/psLib/test/astronomy/tst_psTime_01.c
r1406 r1615 21 21 * @author Ross Harman, MHPCC 22 22 * 23 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $24 * @date $Date: 2004-08- 06 22:34:05$23 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2004-08-25 01:38:42 $ 25 25 * 26 26 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 int main(int argc, char* argv[]) 35 35 { 36 psTime time; 37 psTime testTime; 38 char *testString = "2004/07/21,18:22:24.272"; 36 psTime *time; 37 psTime *testTime; 38 char *testString = "2004-07-21T18:22:24.272Z"; 39 time = (psTime*)psAlloc(sizeof(psTime)); 39 40 40 41 // Test time was taken at July 21, 2004 at 18:22:24.272044 41 testTime.tv_sec = 1090434144; 42 testTime.tv_usec = 272044; 42 testTime = (psTime*)psAlloc(sizeof(psTime)); 43 testTime->sec = 1090434144; 44 testTime->usec = 272044; 45 testTime->type = PS_TIME_TAI; 43 46 44 47 45 48 // Test A - Get current TAI time 46 49 printPositiveTestHeader(stdout,"psTime", "Get current TAI time"); 47 time = psTimeGetTime( );50 time = psTimeGetTime(PS_TIME_TAI); 48 51 printFooter(stdout, "psTime", "Get current TAI time", true); 49 52 … … 51 54 //Test B - Print test time 52 55 printPositiveTestHeader(stdout,"psTime", "Print test time"); 53 printf("Test time: Seconds = %ld Microseconds = %ld\n", (long)testTime .tv_sec, (long)testTime.tv_usec);56 printf("Test time: Seconds = %ld Microseconds = %ld\n", (long)testTime->sec, (long)testTime->usec); 54 57 printFooter(stdout, "psTime", "Print test time", true); 55 58 … … 70 73 printPositiveTestHeader(stdout,"psTime", "Convert ISO time to psTime"); 71 74 time = psISOToTime(isoString); 72 printf("psTime: Seconds = %l d Microseconds = %ld\n", (long)time.tv_sec, (long)time.tv_usec);75 printf("psTime: Seconds = %lld Microseconds = %d\n", (psS64)time->sec, (psU32)time->usec); 73 76 psFree(isoString); 74 77 printFooter(stdout, "psTime", "Convert ISO time to psTime", true); 75 78 76 79 77 // Test E - Convert psTimeto UTC time80 // Test E - Convert TAI to UTC time 78 81 printPositiveTestHeader(stdout,"psTime", "Convert psTime time to UTC time"); 79 time = psTime ToUTC(testTime);80 printf("psTime: Seconds = %l d Microseconds = %ld\n", (long)time.tv_sec, (long)time.tv_usec);82 time = psTimeConvert(testTime, PS_TIME_UTC); 83 printf("psTime: Seconds = %lld Microseconds = %d\n", (psS64)time->sec, (psU32)time->usec); 81 84 printFooter(stdout, "psTime", "Convert psTime time to UTC time", true); 82 85 … … 84 87 // Test F - Convert UTC time to psTime 85 88 printPositiveTestHeader(stdout,"psTime", "Convert UTC time to psTime"); 86 time = psUTCToTime(time); 87 printf("psTime: Seconds = %ld Microseconds = %ld\n", (long)time.tv_sec, (long)time.tv_usec); 89 time->type = PS_TIME_UTC; 90 time = psTimeConvert(time, PS_TIME_TAI); 91 printf("psTime: Seconds = %lld Microseconds = %d\n", (psS64)time->sec, (psU32)time->usec); 88 92 printFooter(stdout, "psTime", "Convert UTC time to psTime", true); 89 93 … … 100 104 printPositiveTestHeader(stdout,"psTime", "Convert MJD time to psTime"); 101 105 time = psMJDToTime(mjdTime); 102 printf("psTime: Seconds = %l d Microseconds = %ld\n", (long)time.tv_sec, (long)time.tv_usec);106 printf("psTime: Seconds = %lld Microseconds = %d\n", (psS64)time->sec, (psU32)time->usec); 103 107 printFooter(stdout, "psTime", "Convert MJD time to psTime", true); 104 108 … … 115 119 printPositiveTestHeader(stdout,"psTime", "Convert JD time to psTime"); 116 120 time = psJDToTime(jdTime); 117 printf("psTime: Seconds = %l d Microseconds = %ld\n", (long)time.tv_sec, (long)time.tv_usec);121 printf("psTime: Seconds = %lld Microseconds = %d\n", (psS64)time->sec, (psU32)time->usec); 118 122 printFooter(stdout, "psTime", "Convert JD time to psTime", true); 119 123 … … 130 134 printPositiveTestHeader(stdout,"psTime", "Convert timeval time to psTime"); 131 135 time = psTimevalToTime(&timevalTime); 132 printf("psTime: Seconds = %l d Microseconds = %ld\n", (long)time.tv_sec, (long)time.tv_usec);136 printf("psTime: Seconds = %lld Microseconds = %d\n", (psS64)time->sec, (psU32)time->usec); 133 137 printFooter(stdout, "psTime", "Convert timeval time to psTime", true); 134 138 … … 151 155 printPositiveTestHeader(stdout, "psTime", "Convert tm time to psTime"); 152 156 time = psTMToTime(tmTime); 153 printf("psTime: Seconds = %l d Microseconds = %ld\n", (long)time.tv_sec, (long)time.tv_usec);157 printf("psTime: Seconds = %lld Microseconds = %d\n", (psS64)time->sec, (psU32)time->usec); 154 158 printFooter(stdout, "psTime", "Convert tm time to psTime", true); 155 159 -
trunk/psLib/test/astronomy/tst_psTime_02.c
r1406 r1615 4 4 * 5 5 * This test driver contains the following tests for psTime: 6 * A) Attempt to use negative seconds 7 * B) Attempt to use negative microseconds 8 * C) Attempt to use negative time 9 * D) Incorrect ISO time data 10 * E) Attempt to use null timeval 11 * F) Incorrect timeval time data 6 * A) Incorrect ISO time data 7 * B) Attempt to use null timeval 12 8 * 13 9 * @author Ross Harman, MHPCC 14 10 * 15 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-08- 06 22:34:05$11 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-08-25 01:38:48 $ 17 13 * 18 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 25 21 int main(int argc, char* argv[]) 26 22 { 27 psTime testTime;28 struct timeval timevalTime;29 23 30 31 // Test A - Attempt to use negative seconds 32 testTime.tv_sec = -1; 33 testTime.tv_usec = 1; 34 timevalTime.tv_sec = -1; 35 timevalTime.tv_usec = 1; 36 printNegativeTestHeader(stdout,"psTime", "Attempt to use negative seconds", 37 "Negative seconds are not allowed: -1", 0); 38 psTimeToISO(testTime); 39 psTimeToUTC(testTime); 40 psUTCToTime(testTime); 41 psTimeToMJD(testTime); 42 psTimeToJD(testTime); 43 psTimeToTimeval(testTime); 44 psTimevalToTime(&timevalTime); 45 psTimeToTM(testTime); 46 printFooter(stdout, "psTime", "Attempt to use negative seconds", true); 47 48 49 // Test B - Attempt to use negative microseconds 50 testTime.tv_sec = 1; 51 testTime.tv_usec = -1; 52 timevalTime.tv_sec = 1; 53 timevalTime.tv_usec = -1; 54 printNegativeTestHeader(stdout,"psTime", "Attempt to use negative microseconds", 55 "Negative microseconds are not allowed: -1", 0); 56 psTimeToISO(testTime); 57 psTimeToUTC(testTime); 58 psUTCToTime(testTime); 59 psTimeToMJD(testTime); 60 psTimeToJD(testTime); 61 psTimeToTimeval(testTime); 62 psTimevalToTime(&timevalTime); 63 psTimeToTM(testTime); 64 printFooter(stdout, "psTime", "Attempt to use negative microseconds", true); 65 66 67 // Test C - Attempt to use negative time 68 printNegativeTestHeader(stdout,"psTime", "Attempt to use negative time", 69 "Negative time is not allowed: -1.000000", 0); 70 psJDToTime(-1.0); 71 psMJDToTime(-1.0); 72 printFooter(stdout, "psTime", "Attempt to use negative time", true); 73 74 75 // Test D - Incorrect ISO time data 24 // Test A - Incorrect ISO time data 76 25 printNegativeTestHeader(stdout,"psTime", "Incorrect ISO time data", "Time not allowed", 0); 77 psISOToTime("1800/2/2,12:12:12.122"); 78 psISOToTime("2004/-2/2,12:12:12.122"); 79 psISOToTime("2004/2/-2,12:12:12.122"); 80 psISOToTime("2004/2/2,-12:12:12.122"); 81 psISOToTime("2004/2/2,12:-12:12.122"); 82 psISOToTime("2004/2/2,12:12:-12.122"); 83 psISOToTime("2004/2/2,12:12:12.-122"); 26 psISOToTime("2004-99-21T18:22:24.272Z"); 27 psISOToTime("2004-07-99T18:22:24.272Z"); 28 psISOToTime("2004-07-21T99:22:24.272Z"); 29 psISOToTime("2004-07-21T18:99:24.272Z"); 30 psISOToTime("2004-07-21T18:22:99.272Z"); 31 psISOToTime("2004-07-21T18:22:24.-999Z"); 84 32 printFooter(stdout, "psTime", "Incorrect ISO time data", true); 85 33 86 34 87 // Test E- Attempt to use null timeval35 // Test B - Attempt to use null timeval 88 36 printNegativeTestHeader(stdout,"psTime", "Attempt to use null timeval", 89 37 "Null value for timeval arg not allowed", 0); … … 91 39 printFooter(stdout, "psTime", "Attempt to use null timeval", true); 92 40 93 94 // Test F - Incorrect timeval time data95 printNegativeTestHeader(stdout,"psTime", "Incorrect timeval time data", "Time not allowed", 0);96 struct tm tmTime;97 tmTime.tm_year = -2;98 tmTime.tm_mon = 2;99 tmTime.tm_mday = 2;100 tmTime.tm_hour = 2;101 tmTime.tm_min = 2;102 tmTime.tm_sec = 2;103 psTMToTime(&tmTime);104 tmTime.tm_year = 100;105 tmTime.tm_mon = -2;106 psTMToTime(&tmTime);107 tmTime.tm_mon = 2;108 tmTime.tm_mday = -2;109 psTMToTime(&tmTime);110 tmTime.tm_hour = -2;111 tmTime.tm_mday = 2;112 psTMToTime(&tmTime);113 tmTime.tm_hour = 2;114 tmTime.tm_min = -2;115 psTMToTime(&tmTime);116 tmTime.tm_min = 2;117 tmTime.tm_sec = -2;118 psTMToTime(&tmTime);119 printFooter(stdout, "psTime", "Incorrect timeval time data", true);120 121 41 return 0; 122 42 }
Note:
See TracChangeset
for help on using the changeset viewer.
