Index: /trunk/psLib/test/astronomy/tst_psTime_01.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psTime_01.c	(revision 4058)
+++ /trunk/psLib/test/astronomy/tst_psTime_01.c	(revision 4059)
@@ -4,25 +4,25 @@
  *
  *  This test driver contains the following tests for psTime:
- *     A) Get current TAI time
- *     B) Print test time
- *     C) Convert psTime to ISO time
- *     D) Convert ISO time to psTime
- *     E) Convert psTime to UTC time
- *     F) Convert UTC time to psTime
- *     G) Convert psTime to MJD time
- *     H) Convert MJD time to psTime
- *     I) Convert psTime to JD time
- *     J) Convert JD time to psTime
- *     K) Convert psTime to timeval time
- *     L) Convert timeval time to psTime
- *     M) Convert psTime to tm time
- *     N) Convert tm time to psTime
+ *     1) Allocate psTime structure
+ *     2) Get current time
+ *     3) Get UT1 UTC delta
+ *     4) Convert psTime to MJD
+ *     5) Convert psTime to JD
+ *     6) Convert psTime to ISO
+ *     7) Convert psTime to timeval
+ *     8) Create psTime from MJD
+ *     9) Create psTime from JD
+ *    10) Create psTime from ISO
+ *    11) Create psTime from timeval
+ *    12) Create psTime from TM
+ *    13) Convert time between different types
+ *
  *     O) Convert psTime time to LMST
- *     P) Free data
  *
  *  @author  Ross Harman, MHPCC
+ *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.25 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-04-19 02:13:53 $
+ *  @version $Revision: 1.26 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-05-31 21:56:31 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -30,202 +30,1131 @@
  */
 
-#include <string.h>
 #include "pslib_strict.h"
 #include "psTest.h"
+#include <string.h>
+
+#define ERROR_TOL    0.0001
+
+static psS32 testTimeAlloc(void);
+static psS32 testTimeGetNow(void);
+static psS32 testTimeGetUT1Delta(void);
+static psS32 testTimeToMJD(void);
+static psS32 testTimeToJD(void);
+static psS32 testTimeToISO(void);
+static psS32 testTimeToTimeval(void);
+static psS32 testTimeFromMJD(void);
+static psS32 testTimeFromJD(void);
+static psS32 testTimeFromISO(void);
+static psS32 testTimeFromTimeval(void);
+static psS32 testTimeFromTM(void);
+static psS32 testTimeConvert(void);
+
+testDescription tests[] = {
+                              {testTimeAlloc,000,"psTimeAlloc",0,false},
+                              {testTimeGetNow,000,"psTimeGetNow",0,false},
+                              {testTimeGetUT1Delta,000,"psTimeGetUT1Delta",0,false},
+                              {testTimeToMJD,000,"psTimeToMJD",0,false},
+                              {testTimeToJD,000,"psTimeToJD",0,false},
+                              {testTimeToISO,000,"psTimeToISO",0,false},
+                              {testTimeToTimeval,000,"psTimeToTimeval",0,false},
+                              {testTimeFromMJD,000,"psTimeFromMJD",0,false},
+                              {testTimeFromJD,000,"psTimeFromJD",0,false},
+                              {testTimeFromISO,000,"psTimeFromISO",0,false},
+                              {testTimeFromTimeval,000,"psTimeFromTimeval",0,false},
+                              {testTimeFromTM,000,"p_psTimeFromTM",0,false},
+                              {testTimeConvert,000,"psTimeConvert",0,false},
+                              {NULL}
+                          };
+
+// Test Time 1 : July 21, 2004  18:22:24.3
+//               MJD = 53207.765559
+//               JD = 2453208.265559
+// UTC Test Time 1
+const psS64 testTime1SecondsUTC     = 1090434144;
+const psU32 testTime1NanosecondsUTC = 272044000;
+// TAI Test Time 1
+const psS64 testTime1SecondsTAI     = 1090434176;
+const psU32 testTime1NanosecondsTAI = 272044000;
+const psF64 testTime1MJDTAI         = 53207.76592937;
+const psF64 testTime1JDTAI          = 2453208.26592937;
+
+// TT Test Time 1
+const psS64 testTime1SecondsTT      = 1090434208;
+const psU32 testTime1NanosecondsTT  = 456044000;
+// Expected UT1-UTC IERS A & B
+const psF64 testTime1UT1DeltaBullA  = -0.457233186;
+const psF64 testTime1UT1DeltaBullB  = -0.457227;
+// UT1 Test Time 1
+const psS64 testTime1SecondsUT1     = 1090434143;
+const psU32 testTime1NanosecondsUT1 = 814810814;
+// Expected MJD & JD
+const psF64 testTime1MJD            = 53207.765559;
+const psF64 testTime1JD             = 2453208.265559;
+// Expected ISO string
+const char* testTime1Str     = "2004-07-21T18:22:24,2Z";
+const char* testTime1StrLeap = "2004-07-21T18:22:60,2Z";
+// Expected timeval values
+const psS32 testTime1TimevalSec = 1090434144;
+const psS32 testTime1TimevalUsec = 272044;
+
+// Test Time 2 : Jan. 1, 1973 00:00:00.0000
+//               MJD = 41683.0000
+//               JD = 2441683.5000
+const psS64 testTime2SecondsUTC     = 94694400;
+const psU32 testTime2NanosecondsUTC = 0;
+
+// Expected UT1-UTC IERS A & B
+const psF64 testTime2UT1DeltaBullA  = 0.000000;
+const psF64 testTime2UT1DeltaBullB  = 0.000000;
+
+// Test Time 3 : Sept. 21, 2006 00:00:00.0000
+//               MJD = 53999
+//               JD = 2453999.5
+const psS64 testTime3SecondsUTC     = 1158796800;
+const psU32 testTime3NanosecondsUTC = 0;
+// Expected UT1-UTC IERS A & B
+const psF64 testTime3UT1DeltaBullA  = -0.63574;
+const psF64 testTime3UT1DeltaBullB  = -0.63574;
+
+// Test Time 4 : Jan. 1, 1969 00:00:00.0000
+//               MJD = 40222
+//               JD = 2440222.5
+const psS64 testTime4SecondsUTC     = -31536000;
+const psU32 testTime4NanosecondsUTC = 0;
+// Expected MJD and JD
+const psF64 testTime4MJD            = 40222.0;
+const psF64 testTime4JD             = 2440222.5;
+
+// Test Time 5 : Dec 31, 0001 BC 23:59:59
+//               MJD = -1397755
+//               JD = 1002245.4999
+const psS64 testTime5SecondsUTC     = -62125920001;
+const psU32 testTime5NanosecondsUTC  = 0;
+
+// Test Time 6 : Jan. 1, 10000 AD 00:00:00
+const psS64 testTime6SecondsUTC      = 253202544001;
+const psU32 testTime6NanosecondsUTC  = 0;
+
+// Test Time 7 : Jan. 1, 2004 00:00:00,0
+const psS64 testTime7Seconds         = 1072915200;
+const psU32 testTime7Nanoseconds     = 0;
+const psS32 testTime7TmYear          = 104;
+const psS32 testTime7TmMon           = 0;
+const psS32 testTime7TmDay           = 1;
+const psS32 testTime7TmHour          = 0;
+const psS32 testTime7TmMin           = 0;
+const psS32 testTime7TmSec           = 0;
+
+// Test Time 8 : Dec. 31, 2003 00:00:00,0
+const psS64 testTime8Seconds         = 1072828800;
+const psU32 testTime8Nanoseconds     = 0;
+const psS32 testTime8TmYear          = 103;
+const psS32 testTime8TmMon           = 11;
+const psS32 testTime8TmDay           = 31;
+const psS32 testTime8TmHour          = 0;
+const psS32 testTime8TmMin           = 0;
+const psS32 testTime8TmSec           = 0;
 
 psS32 main(psS32 argc, char* argv[])
 {
-    psTime *testTime;
-    char *testString = "2004-07-21T18:22:24.272Z";
-
+    psLogSetLevel(PS_LOG_INFO);
+
+    // Initialize library internal structures
     psLibInit(true,"psTime.config");
 
-    // Test time was taken at July 21, 2004 at 18:22:24.272044
-    testTime = (psTime*)psAlloc(sizeof(psTime));
-    testTime->sec = 1090434144;
-    testTime->nsec = 272044000;
-    testTime->type = PS_TIME_TAI;
-
-    // Test A - Get current TAI time
-    printPositiveTestHeader(stdout,"psTime", "Get current TAI time");
-    psTime *timeA = NULL;
-    timeA = psTimeGetNow(PS_TIME_TAI);
-    psFree(timeA);
-    printFooter(stdout, "psTime", "Get current TAI time", true);
-
-
-    // Test B - Print test time
-    printPositiveTestHeader(stdout,"psTime", "Print test time");
-    printf("Test time: Seconds = %lld Nanoseconds = %u\n",
-           (long long int)testTime->sec,
-           testTime->nsec);
-    printFooter(stdout, "psTime", "Print test time", true);
-
-
-    // Test C - Convert psTime to ISO time
-    printPositiveTestHeader(stdout,"psTime", "Convert psTime to ISO time");
-    char *isoString;
-    isoString = psTimeToISO(testTime);
-    printf("%s\n", isoString);
-    if(strncmp(isoString, testString, 256)) {
-        printf("ERROR - ISO string incorrect\n");
-        printf("Returned: %s\n", isoString);
-    }
-    printFooter(stdout, "psTime", "Convert psTime to ISO time", true);
-
-
-    // Test D - Convert ISO time to psTime
-    printPositiveTestHeader(stdout,"psTime", "Convert ISO time to psTime");
-    psTime *timeD = NULL;
-    timeD = psTimeFromISO(isoString);
-    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
-           (long long int)timeD->sec,
-           timeD->nsec);
-    psFree(isoString);
-    psFree(timeD);
-    printFooter(stdout, "psTime", "Convert ISO time to psTime", true);
-
-
-    // Test E - Convert TAI to UTC time
-    printPositiveTestHeader(stdout,"psTime", "Convert psTime time to UTC time");
-    psTime *timeE = NULL;
-    timeE = (psTime*)psAlloc(sizeof(psTime));
-    timeE->sec = 1090434144;
-    timeE->nsec = 272044000;
-    timeE->type = PS_TIME_TAI;
-    timeE = psTimeConvert(timeE, PS_TIME_UTC);
-    psFree(timeE);
-    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
-           (long long int)timeE->sec,
-           timeE->nsec);
-    printFooter(stdout, "psTime", "Convert psTime time to UTC time", true);
-
-
-    // Test F - Convert UTC time to psTime
-    printPositiveTestHeader(stdout,"psTime", "Convert UTC time to psTime");
-    psTime *timeF = NULL;
-    timeF = (psTime*)psAlloc(sizeof(psTime));
-    timeF->sec = 1090434112;
-    timeF->nsec = 272044000;
-    timeF->type = PS_TIME_UTC;
-    timeF = psTimeConvert(timeF, PS_TIME_TAI);
-    psFree(timeF);
-    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
-           (long long int)timeF->sec,
-           timeF->nsec);
-    printFooter(stdout, "psTime", "Convert UTC time to psTime", true);
-
-
-    // Test G - Convert psTime to MJD time
-    printPositiveTestHeader(stdout,"psTime", "Convert psTime to MJD time");
-    double mjdTime = 0.0;
-    mjdTime = psTimeToMJD(testTime);
-    printf("MJD = %f\n", mjdTime);
-    printFooter(stdout, "psTime", "Convert psTime to MJD time", true);
-
-
-    // Test H - Convert MJD time to psTime
-    printPositiveTestHeader(stdout,"psTime", "Convert MJD time to psTime");
-    psTime *timeH = NULL;
-    timeH = psTimeFromMJD(mjdTime);
-    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
-           (long long int)timeH->sec,
-           timeH->nsec);
-    psFree(timeH);
-    printFooter(stdout, "psTime", "Convert MJD time to psTime", true);
-
-
-    // Test I - Convert psTime to JD time
-    printPositiveTestHeader(stdout,"psTime", "Convert psTime to JD time");
-    double jdTime = 0.0;
-    jdTime = psTimeToJD(testTime);
-    printf("JD = %f\n", jdTime);
-    printFooter(stdout, "psTime", "Convert psTime to JD time", true);
-
-
-    // Test J - Convert JD time to psTime
-    printPositiveTestHeader(stdout,"psTime", "Convert JD time to psTime");
-    psTime *timeJ = NULL;
-    timeJ = psTimeFromJD(jdTime);
-    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
-           (long long int)timeJ->sec,
-           timeJ->nsec);
-    psFree(timeJ);
-    printFooter(stdout, "psTime", "Convert JD time to psTime", true);
-
-
-    // Test K - Convert psTime to timeval time
-    printPositiveTestHeader(stdout,"psTime", "Convert psTime to timeval time");
-    struct timeval timevalTime;
-    timevalTime = psTimeToTimeval(testTime);
-    printf("timevalTime: Seconds = %lld Microseconds = %lld\n",
-           (long long int)timevalTime.tv_sec,
-           (long long int)timevalTime.tv_usec);
-    printFooter(stdout, "psTime", "Convert psTime to timeval time", true);
-
-
-    // Test L - Convert timeval time to psTime
-    printPositiveTestHeader(stdout,"psTime", "Convert timeval time to psTime");
-    psTime *timeL = NULL;
-    timeL = psTimeFromTimeval(&timevalTime);
-    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
-           (long long int)timeL->sec,
-           timeL->nsec);
-    psFree(timeL);
-    printFooter(stdout, "psTime", "Convert timeval time to psTime", true);
-
-
-    // Test M - Convert psTime to tm time
-    printPositiveTestHeader(stdout,"psTime", "Convert psTime to tm time");
-    struct tm *tmTime;
-    tmTime = psTimeToTM(testTime);
-    printf("tmTime:\n");
-    printf("tmTime->tm_year = %d\n", tmTime->tm_year);
-    printf("tmTime->tm_mon = %d\n", tmTime->tm_mon);
-    printf("tmTime->tm_mday = %d\n", tmTime->tm_mday);
-    printf("tmTime->tm_hour = %d\n", tmTime->tm_hour);
-    printf("tmTime->tm_min = %d\n", tmTime->tm_min);
-    printf("tmTime->tm_sec = %d\n", tmTime->tm_sec);
-    printFooter(stdout, "psTime", "Convert psTime to tm time", true);
-
-
-    // Test N - Convert tm time to psTime
-    printPositiveTestHeader(stdout, "psTime", "Convert tm time to psTime");
-    psTime *timeN = NULL;
-    timeN = psTimeFromTM(tmTime);
-    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
-           (long long int)timeN->sec,
-           timeN->nsec);
-    psFree(timeN);
+    if( !runTestSuite(stderr,"psTime",tests,argc,argv)) {
+        return 1;
+    }
+
+    // Cleanup library
+    psLibFinalize();
+
+    return 0;
+}
+
+psS32 testTimeAlloc(void)
+{
+    psTime*  time = NULL;
+
+    // Allocate new psTime with valid time type
+    time = psTimeAlloc(PS_TIME_TAI);
+    if(time == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Return NULL when psTime object ptr expected");
+        return 1;
+    }
+    // Verify members set properly
+    if(time->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Member type = %d not as expected %d",time->type,PS_TIME_TAI);
+        return 2;
+    }
+    if((time->sec != 0) && (time->nsec != 0) && (time->leapsecond != false)) {
+        psError(PS_ERR_UNKNOWN,true,"Members not set appropriately");
+        return 3;
+    }
+    psFree(time);
+
+    // Allocate new psTime with invalid time type
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    time = psTimeAlloc(-100);
+    if(time != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid time type");
+        return 4;
+    }
+
+    return 0;
+}
+psS32 testTimeGetNow(void)
+{
+    psTime*  timeNow = NULL;
+
+    // Get current time and verify return is psTime structure
+    timeNow = psTimeGetNow(PS_TIME_TAI);
+    if(timeNow == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return valid psTime struct");
+        return 1;
+    }
+    if(timeNow->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Time type %d not as expected %d",
+                timeNow->type, PS_TIME_TAI);
+        return 2;
+    }
+    psFree(timeNow);
+
+    // Attempt to get time with invalid type
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid time type");
+    timeNow = psTimeGetNow(-100);
+    if(timeNow != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid time type");
+        return 3;
+    }
+
+    return 0;
+}
+
+psS32 testTimeGetUT1Delta(void)
+{
+    psTime*    time      = NULL;
+    psF64      ut1Delta  = 0.0;
+
+    // Attempt to convert NULL time
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL time");
+    ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
+    if( !isnan(ut1Delta)) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NAN for NULL psTime");
+        return 1;
+    }
+
+    // Attempt to convert invalid time
+    time = psTimeAlloc(PS_TIME_TAI);
+    time->sec = 1;
+    time->nsec = 2e9;
+    time->leapsecond = false;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid time");
+    ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
+    if( !isnan(ut1Delta)) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NAN for invalid time");
+        return 2;
+    }
+
+    // Attempt to convert time with invalid bulletin
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid bulletin");
+    time->nsec = 2;
+    ut1Delta = psTimeGetUT1Delta(time,-100);
+    if( !isnan(ut1Delta)) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NAN for invalid bulletin");
+        return 3;
+    }
+
+    // Attempt to get delta with valid time and bulletin A
+    time->sec  = testTime1SecondsUTC;
+    time->nsec = testTime1NanosecondsUTC;
+    time->type = PS_TIME_UTC;
+    ut1Delta = psTimeGetUT1Delta(time,PS_IERS_A);
+    if(fabs(ut1Delta - testTime1UT1DeltaBullA) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 Delta %lf not as expected %lf test time 1 bulletin A",
+                ut1Delta,testTime1UT1DeltaBullA);
+        return 4;
+    }
+
+    // Attempt to get delta with valid time and bulletin B
+    ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
+    if(fabs(ut1Delta - testTime1UT1DeltaBullB) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 Delta %lf not as expected %lf test time 1 bulletin B",
+                ut1Delta,testTime1UT1DeltaBullB);
+        return 5;
+    }
+
+    // Attempt to get delta with valid time and bulletin A
+    time->sec  = testTime2SecondsUTC;
+    time->nsec = testTime2NanosecondsUTC;
+    time->type = PS_TIME_UTC;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate a warning message predating table");
+    ut1Delta = psTimeGetUT1Delta(time,PS_IERS_A);
+    if(fabs(ut1Delta - testTime2UT1DeltaBullA) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 Delta %lf not as expected %lf test time 2 bulletin A",
+                ut1Delta,testTime2UT1DeltaBullA);
+        return 6;
+    }
+
+    // Attempt to get delta with valid time and bulletin B
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate a warning message predating table");
+    ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
+    if(fabs(ut1Delta - testTime2UT1DeltaBullB) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 Delta %lf not as expected %lf test time 2 bulletin B",
+                ut1Delta,testTime2UT1DeltaBullB);
+        return 7;
+    }
+
+    // Attempt to get delta with valid time and bulletin A
+    time->sec  = testTime3SecondsUTC;
+    time->nsec = testTime3NanosecondsUTC;
+    time->type = PS_TIME_UTC;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate a warning message postdating table");
+    ut1Delta = psTimeGetUT1Delta(time,PS_IERS_A);
+    if(fabs(ut1Delta - testTime3UT1DeltaBullA) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 Delta %lf not as expected %lf test time 3 bulletin A",
+                ut1Delta,testTime3UT1DeltaBullA);
+        return 8;
+    }
+
+    // Attempt to get delta with valid time and bulletin B
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate a warning message postdating table");
+    ut1Delta = psTimeGetUT1Delta(time,PS_IERS_B);
+    if(fabs(ut1Delta - testTime3UT1DeltaBullB) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 Delta %lf not as expected %lf test time 3 bulletin B",
+                ut1Delta,testTime3UT1DeltaBullB);
+        return 9;
+    }
+
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeToMJD(void)
+{
+    psTime*  time = NULL;
+    psF64    mjd  = 0.0;
+
+    // Attempt to convert with time NULL
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL time");
+    mjd = psTimeToMJD(NULL);
+    if(!isnan(mjd)) {
+        psError(PS_ERR_UNKNOWN,true,"Expected NaN for NULL time");
+        return 1;
+    }
+
+    // Attempt to convert invalid time
+    time = psTimeAlloc(PS_TIME_UTC);
+    time->sec = 1;
+    time->nsec = 2e9;
+    time->leapsecond = false;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid time");
+    mjd = psTimeToMJD(time);
+    if( !isnan(mjd)) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NAN for invalid time");
+        return 2;
+    }
+
+    // Check valid time conversion to MJD after 1/1/1970 epoch
+    time->sec = testTime1SecondsUTC;
+    time->nsec = testTime1NanosecondsUTC;
+    mjd = psTimeToMJD(time);
+    if(fabs(mjd - testTime1MJD) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Expected MJD = %lf not as expected %lf",
+                mjd, testTime1MJD);
+        return 3;
+    }
+
+    // Check valid time conversion to MJD before 1/1/1970 epoch
+    time->sec = testTime4SecondsUTC;
+    time->nsec = testTime4NanosecondsUTC;
+    mjd = psTimeToMJD(time);
+    if(fabs(mjd - testTime4MJD) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Expected MJD = %lf not as expected %lf",
+                mjd, testTime4MJD);
+        return 4;
+    }
+
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeToJD(void)
+{
+    psTime*  time = NULL;
+    psF64    jd  = 0.0;
+
+    // Attempt to convert with time NULL
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL time");
+    jd = psTimeToJD(NULL);
+    if(!isnan(jd)) {
+        psError(PS_ERR_UNKNOWN,true,"Expected NaN for NULL time");
+        return 1;
+    }
+
+    // Attempt to convert invalid time
+    time = psTimeAlloc(PS_TIME_UTC);
+    time->sec = 1;
+    time->nsec = 2e9;
+    time->leapsecond = false;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid time");
+    jd = psTimeToJD(time);
+    if( !isnan(jd)) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NAN for invalid time");
+        return 2;
+    }
+
+    // Check valid time conversion to MJD after 1/1/1970 epoch
+    time->sec = testTime1SecondsUTC;
+    time->nsec = testTime1NanosecondsUTC;
+    jd = psTimeToJD(time);
+    if(fabs(jd - testTime1JD) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Expected JD = %lf not as expected %lf",
+                jd, testTime1JD);
+        return 3;
+    }
+
+    // Check valid time conversion to MJD before 1/1/1970 epoch
+    time->sec = testTime4SecondsUTC;
+    time->nsec = testTime4NanosecondsUTC;
+    jd = psTimeToJD(time);
+    if(fabs(jd - testTime4JD) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Expected JD = %lf not as expected %lf",
+                jd, testTime4JD);
+        return 4;
+    }
+
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeToISO(void)
+{
+    psTime*    time    = NULL;
+    char*      timeStr = NULL;
+
+    // Attempt to convert with NULL time
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL time");
+    timeStr = psTimeToISO(time);
+    if(timeStr != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected");
+        return 1;
+    }
+
+    // Attempt to convert invalid time
+    time = psTimeAlloc(PS_TIME_UTC);
+    time->sec = 1;
+    time->nsec = 2e9;
+    time->leapsecond = false;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid time");
+    timeStr = psTimeToISO(time);
+    if( timeStr != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid time");
+        return 2;
+    }
+
+    // Verify return NULL for time prior to year 0000
+    time->sec = testTime5SecondsUTC;
+    time->nsec = testTime5NanosecondsUTC;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for time prior year 0000");
+    timeStr = psTimeToISO(time);
+    if(timeStr != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for time prior to year 0000");
+        return 3;
+    }
+
+    // Verify return NULL for time after to year 9999
+    time->sec = testTime6SecondsUTC;
+    time->nsec = testTime6NanosecondsUTC;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for time after year 9999");
+    timeStr = psTimeToISO(time);
+    if(timeStr != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for time after to year 9999");
+        return 4;
+    }
+
+    // Verify return string with valid time
+    time->sec = testTime1SecondsUTC;
+    time->nsec = testTime1NanosecondsUTC;
+    timeStr = psTimeToISO(time);
+    if(strcmp(timeStr,testTime1Str) != 0) {
+        psError(PS_ERR_UNKNOWN,true,"String %s not as expected %s",
+                timeStr, testTime1Str);
+        return 5;
+    }
+    psFree(timeStr);
+
+    // Verify return string with valid time and leap second set
+    time->sec = testTime1SecondsUTC;
+    time->nsec = testTime1NanosecondsUTC;
+    time->leapsecond = true;
+    timeStr = psTimeToISO(time);
+    if(strcmp(timeStr,testTime1StrLeap) != 0) {
+        psError(PS_ERR_UNKNOWN,true,"String %s not as expected %s",
+                timeStr, testTime1StrLeap);
+        return 6;
+    }
+    psFree(timeStr);
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeToTimeval(void)
+{
+    psTime*           time         = NULL;
+    struct timeval*   timevalTime  = NULL;
+
+    // Attempt to convert with NULL time
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL time");
+    timevalTime = psTimeToTimeval(time);
+    if(timevalTime != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected");
+        return 1;
+    }
+
+    // Attempt to convert invalid time
+    time = psTimeAlloc(PS_TIME_UTC);
+    time->sec = 1;
+    time->nsec = 2e9;
+    time->leapsecond = false;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid time");
+    timevalTime = psTimeToTimeval(time);
+    if( timevalTime != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid time");
+        return 2;
+    }
+
+    // Attempt to convert invalid time
+    time->sec = -1;
+    time->nsec = 0;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid time");
+    timevalTime = psTimeToTimeval(time);
+    if( timevalTime != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid time");
+        return 2;
+    }
+
+    // Verify convert to timeval with valid time
+    time->sec = testTime1SecondsUTC;
+    time->nsec = testTime1NanosecondsUTC;
+    timevalTime = psTimeToTimeval(time);
+    if(timevalTime->tv_sec != testTime1TimevalSec) {
+        psError(PS_ERR_UNKNOWN,true,"Timeval seconds %ld not as expectd %ld",
+                timevalTime->tv_sec,testTime1TimevalSec);
+        return 4;
+    }
+    if(timevalTime->tv_usec != testTime1TimevalUsec) {
+        psError(PS_ERR_UNKNOWN,true,"Timeval useconds %ld not as expected %ld",
+                timevalTime->tv_usec,testTime1TimevalUsec);
+        return 5;
+    }
+
+    psFree(timevalTime);
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeFromMJD(void)
+{
+    psTime*   time = NULL;
+
+    // Attempt to convert valid time to psTime
+    time = psTimeFromMJD(testTime1MJDTAI);
+    if(time->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
+                time->type,PS_TIME_TAI);
+        return 1;
+    }
+    if(time->sec != testTime1SecondsTAI) {
+        psError(PS_ERR_UNKNOWN,true,"psTime seconds %ld not as expected %ld",
+                (long int)time->sec,testTime1SecondsTAI);
+        return 2;
+    }
+    psFree(time);
+
+    // Attempt to convert valid time before 1970 epoch
+    time = psTimeFromMJD(testTime4MJD);
+    if(time->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
+                time->type,PS_TIME_TAI);
+        return 3;
+    }
+    if(time->sec != testTime4SecondsUTC) {
+        psError(PS_ERR_UNKNOWN,true,"psTime seconds %ld not as expected %ld",
+                (long int)time->sec,testTime4SecondsUTC);
+        return 4;
+    }
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeFromJD(void)
+{
+    psTime*   time = NULL;
+
+    // Attempt to convert valid time to psTime
+    time = psTimeFromJD(testTime1JDTAI);
+    if(time->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
+                time->type,PS_TIME_TAI);
+        return 1;
+    }
+    if(time->sec != testTime1SecondsTAI) {
+        psError(PS_ERR_UNKNOWN,true,"psTime seconds %ld not as expected %ld",
+                (long int)time->sec,(long int)testTime1SecondsTAI);
+        return 2;
+    }
+    psFree(time);
+
+    // Attempt to convert valid time before 1970 epoch
+    time = psTimeFromJD(testTime4JD);
+    if(time->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
+                time->type,PS_TIME_TAI);
+        return 3;
+    }
+    if(time->sec != testTime4SecondsUTC) {
+        psError(PS_ERR_UNKNOWN,true,"psTime seconds %ld not as expected %ld",
+                (long int)time->sec,testTime4SecondsUTC);
+        return 4;
+    }
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeFromISO(void)
+{
+    psTime*   time = NULL;
+
+    // Attempt to convert NULL string
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL ISO string");
+    time = psTimeFromISO(NULL);
+    if(time != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected for NULL ISO string");
+        return 1;
+    }
+
+    // Convert valid ISO string
+    time = psTimeFromISO(testTime1Str);
+    if(time->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d",
+                time->type, PS_TIME_TAI);
+        return 2;
+    }
+    if(time->sec != testTime1SecondsUTC) {
+        psError(PS_ERR_UNKNOWN,true,"psTime seconds %ld not as expected %ld",
+                (long int)time->sec,testTime1SecondsTAI);
+        return 3;
+    }
+    psFree(time);
+
+    // Attempt to convert invalid ISO string
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error for invalid ISO string");
+    time = psTimeFromISO("Here I am");
+    if(time != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL as expected for invalid ISO string");
+        return 4;
+    }
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeFromTimeval(void)
+{
+    psTime*          time        = NULL;
+    struct timeval*  timevalTime = NULL;
+
+    // Attempt to create psTime from NULL timeval ptr
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL timeval");
+    time = psTimeFromTimeval(NULL);
+    if(time != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for NULL timeval ptr");
+        return 1;
+    }
+
+    // Convert valid timeval structure
+    timevalTime = (struct timeval*)psAlloc(sizeof(struct timeval));
+    timevalTime->tv_sec = testTime1SecondsTAI;
+    timevalTime->tv_usec = testTime1NanosecondsTAI / 1000;
+    time = psTimeFromTimeval(timevalTime);
+    if(time == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return value for valid timeval");
+        return 2;
+    }
+    if(time->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"psTime type %d not as expected %d",
+                time->type, PS_TIME_TAI);
+        return 3;
+    }
+    if(time->sec != testTime1SecondsTAI) {
+        psError(PS_ERR_UNKNOWN,true,"psTime seconds %ld not as expected %ld",
+                time->sec, testTime1SecondsTAI);
+        return 4;
+    }
+    if(time->nsec != testTime1NanosecondsTAI) {
+        psError(PS_ERR_UNKNOWN,true,"psTime nanosec %ld not as expected %ld",
+                time->nsec, testTime1NanosecondsTAI);
+        return 5;
+    }
+    psFree(timevalTime);
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeFromTM(void)
+{
+    psTime*     time   = NULL;
+    struct tm*  tmTime = NULL;
+
+    // Attempt to convert from NULL tm structure ptr
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL tm ptr");
+    time = p_psTimeFromTM(tmTime);
+    if(time != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for NULL tm ptr");
+        return 1;
+    }
+
+    // Verify convert for valid tm structure
+    tmTime = (struct tm*)psAlloc(sizeof(struct tm));
+    tmTime->tm_year = testTime7TmYear;
+    tmTime->tm_mon  = testTime7TmMon;
+    tmTime->tm_mday = testTime7TmDay;
+    tmTime->tm_hour = testTime7TmHour;
+    tmTime->tm_min  = testTime7TmMin;
+    tmTime->tm_sec  = testTime7TmSec;
+    time = p_psTimeFromTM(tmTime);
+    if(time == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return value for valid tm structure");
+        return 2;
+    }
+    if(time->sec != testTime7Seconds) {
+        psError(PS_ERR_UNKNOWN,true,"psTime seconds %ld not as expected %ld",
+                (long int)time->sec, (long int)testTime7Seconds);
+        return 3;
+    }
+    if(time->nsec != testTime7Nanoseconds) {
+        psError(PS_ERR_UNKNOWN,true,"psTime nanoseconds %ld not as expected %ld",
+                time->nsec, testTime7Nanoseconds);
+        return 4;
+    }
     psFree(tmTime);
-    printFooter(stdout, "psTime", "Convert tm time to psTime", true);
-
-
-    // Test O - psTime to LMST
-    printPositiveTestHeader(stdout, "psTime", "Convert psTime time to LST");
-    char *testString2 = "2004-09-10T1:00:00.00Z";
-    psTime* testTime2 = NULL;
-    testTime2 = psTimeFromISO(testString2);
-    double dblTime = psTimeToLMST(testTime2, 1);
-    printf("LST (rad): %lf\n", dblTime);
-    psFree(testTime2);
-    printFooter(stdout, "psTime", "Convert psTime time to LST", true);
-
-
-    // Test P - Free data
-    printPositiveTestHeader(stdout, "psMetadata", "Test P - Free data");
-    psFree(testTime);
-    psLibFinalize();
-    if( psMemCheckLeaks(0, NULL, stdout,false) != 0 ) {
-        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected");
+    psFree(time);
+
+    // Verify convert for valid tm structure
+    tmTime = (struct tm*)psAlloc(sizeof(struct tm));
+    tmTime->tm_year = testTime8TmYear;
+    tmTime->tm_mon  = testTime8TmMon;
+    tmTime->tm_mday = testTime8TmDay;
+    tmTime->tm_hour = testTime8TmHour;
+    tmTime->tm_min  = testTime8TmMin;
+    tmTime->tm_sec  = testTime8TmSec;
+    time = p_psTimeFromTM(tmTime);
+    if(time == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return value for valid tm structure");
+        return 2;
+    }
+    if(time->sec != testTime8Seconds) {
+        psError(PS_ERR_UNKNOWN,true,"psTime seconds %ld not as expected %ld",
+                (long int)time->sec, (long int)testTime8Seconds);
+        return 3;
+    }
+    if(time->nsec != testTime8Nanoseconds) {
+        psError(PS_ERR_UNKNOWN,true,"psTime nanoseconds %ld not as expected %ld",
+                time->nsec, testTime8Nanoseconds);
+        return 4;
+    }
+    psFree(tmTime);
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeConvert(void)
+{
+    psTime*  time1 = NULL;
+    psTime*  time2 = NULL;
+
+    // Attempt to convert NULL time
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL time");
+    time2 = psTimeConvert(time1,PS_TIME_TAI);
+    // Verify return value is NULL
+    if(time2 != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for NULL time specified");
+        return 1;
+    }
+
+    // Attempt to convert to invalid type
+    time1 = psTimeAlloc(PS_TIME_TAI);
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid type");
+    time2 = psTimeConvert(time1,-100);
+    // Verify return value is NULL
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for invalid type to convert to");
+        return 2;
+    }
+    time1->type = PS_TIME_UTC;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid type");
+    time2 = psTimeConvert(time1,-100);
+    // Verify return value is NULL
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for invalid type to convert to");
+        return 2;
+    }
+    time1->type = PS_TIME_TT;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid type");
+    time2 = psTimeConvert(time1,-100);
+    // Verify return value is NULL
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for invalid type to convert to");
+        return 2;
+    }
+    time1->type = -100;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid type");
+    time2 = psTimeConvert(time1,PS_TIME_TAI);
+    // Verify return value is NULL
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for invalid type to convert to");
+        return 2;
+    }
+
+    // Attempt to convert with invalid time nsec > 1e9
+    time1->nsec = 2e9;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid time");
+    time2 = psTimeConvert(time1,PS_TIME_TAI);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for invalid time specified");
+        return 3;
+    }
+
+    //Attempt to convert a time to the same type
+    time2 = NULL;
+    time1->sec = 1;
+    time1->nsec = 2;
+    time1->type = PS_TIME_TAI;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_TAI);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion to same type");
+        return 4;
+    }
+    // Verify time not changed
+    if((time2->sec != 1) || (time2->nsec != 2) || (time2->type != PS_TIME_TAI) ||
+            (time2->leapsecond != false) ) {
+        psError(PS_ERR_UNKNOWN,true,"Time member changes when no change expected");
+        return 5;
+    }
+
+    // Attempt to convert a UTC time to a TAI
+    time2 = NULL;
+    time1->sec = testTime1SecondsUTC;
+    time1->nsec = testTime1NanosecondsUTC;
+    time1->type = PS_TIME_UTC;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_TAI);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from UTC to TAI");
+        return 6;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_TAI);
+        return 7;
+    }
+    // Verify time is TAI as expected
+    if(time2->sec != testTime1SecondsTAI) {
+        psError(PS_ERR_UNKNOWN,true,"TAI seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsTAI);
+        return 7;
+    }
+    if(time2->nsec != testTime1NanosecondsTAI) {
+        psError(PS_ERR_UNKNOWN,true,"TAI nanoseconds = %ld not as expected %ld",(long int)time2->nsec,
+                (long int)testTime1NanosecondsTAI);
+        return 8;
+    }
+
+    // Attempt to convert a UTC time to a TT
+    time2 = NULL;
+    time1->sec = testTime1SecondsUTC;
+    time1->nsec = testTime1NanosecondsUTC;
+    time1->type = PS_TIME_UTC;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_TT);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from UTC to TT");
+        return 6;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_TT) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_TT);
+        return 7;
+    }
+    // Verify time is TT as expected
+    if(time2->sec != testTime1SecondsTT) {
+        psError(PS_ERR_UNKNOWN,true,"TT seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsTT);
+        return 7;
+    }
+    if(time2->nsec != testTime1NanosecondsTT) {
+        psError(PS_ERR_UNKNOWN,true,"TT nanoseconds = %ld not as expected %ld",(long int)time2->nsec,
+                (long int)testTime1NanosecondsTT);
+        return 8;
+    }
+
+    // Attempt to convert a UTC time to UT1
+    time2 = NULL;
+    time1->sec = testTime1SecondsUTC;
+    time1->nsec = testTime1NanosecondsUTC;
+    time1->type = PS_TIME_UTC;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_UT1);
+    if(time1 != time2) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from UTC to UT1");
+        return 9;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_UT1) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_UT1);
+        return 7;
+    }
+    // Verify time is UT1 as expected
+    if(time2->sec != testTime1SecondsUT1) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsUT1);
+        return 9;
+    }
+    if(time2->nsec != testTime1NanosecondsUT1) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 nanoseconds = %d not as expected %d",time2->nsec,
+                testTime1NanosecondsUT1);
         return 10;
     }
-    psMemCheckCorruption(0);
-    psS32 nBad = psMemCheckCorruption(0);
-    if(nBad) {
-        printf("ERROR: Found %d bad memory blocks\n", nBad);
-    }
-    printFooter(stdout, "psMetadata", "Test P - Free data", true);
-
-    return 0;
-}
+
+    // Attempt to convert a TAI time to UTC
+    time2 = NULL;
+    time1->sec = testTime1SecondsTAI;
+    time1->nsec = testTime1NanosecondsTAI;
+    time1->type = PS_TIME_TAI;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_UTC);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from TAI to UTC");
+        return 11;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_UTC) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_UTC);
+        return 7;
+    }
+    // Verify time is UTC as expected
+    if(time2->sec != testTime1SecondsUTC) {
+        psError(PS_ERR_UNKNOWN,true,"UTC seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsUTC);
+        return 12;
+    }
+    if(time2->nsec != testTime1NanosecondsUTC) {
+        psError(PS_ERR_UNKNOWN,true,"UTC nanoseconds = %ld not as expected %ld",(long int)time2->nsec,
+                (long int)testTime1NanosecondsUTC);
+        return 13;
+    }
+
+    // Attempt to convert a TAI time to TT
+    time2 = NULL;
+    time1->sec = testTime1SecondsTAI;
+    time1->nsec = testTime1NanosecondsTAI;
+    time1->type = PS_TIME_TAI;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_TT);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from TAI to TT");
+        return 14;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_TT) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_TT);
+        return 7;
+    }
+    // Verify time is TT as expected
+    if(time2->sec != testTime1SecondsTT) {
+        psError(PS_ERR_UNKNOWN,true,"TT seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsTT);
+        return 15;
+    }
+    if(time2->nsec != testTime1NanosecondsTT) {
+        psError(PS_ERR_UNKNOWN,true,"TT nanoseconds = %ld not as expected %ld",(long int)time2->nsec,
+                (long int)testTime1NanosecondsTT);
+        return 16;
+    }
+
+    // Attempt to convert a TAI time to UT1
+    time2 = NULL;
+    time1->sec = testTime1SecondsTAI;
+    time1->nsec = testTime1NanosecondsTAI;
+    time1->type = PS_TIME_TAI;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_UT1);
+    if(time1 != time2) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from TAI to UT1");
+        return 9;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_UT1) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_UT1);
+        return 7;
+    }
+    // Verify time is UT1 as expected
+    if(time2->sec != testTime1SecondsUT1) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsUT1);
+        return 9;
+    }
+    if(time2->nsec != testTime1NanosecondsUT1) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 nanoseconds = %d not as expected %d",time2->nsec,
+                testTime1NanosecondsUT1);
+        return 10;
+    }
+
+    // Attempt to convert a TT time to UTC
+    time2 = NULL;
+    time1->sec = testTime1SecondsTT;
+    time1->nsec = testTime1NanosecondsTT;
+    time1->type = PS_TIME_TT;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_UTC);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from TT to UTC");
+        return 17;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_UTC) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_UTC);
+        return 7;
+    }
+    // Verify time is UTC as expected
+    if(time2->sec != testTime1SecondsUTC) {
+        psError(PS_ERR_UNKNOWN,true,"UTC seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsUTC);
+        return 18;
+    }
+    if(time2->nsec != testTime1NanosecondsUTC) {
+        psError(PS_ERR_UNKNOWN,true,"UTC nanoseconds = %ld not as expected %ld",(long int)time2->nsec,
+                (long int)testTime1NanosecondsUTC);
+        return 19;
+    }
+
+    // Attempt to convert a TT time to TAI
+    time2 = NULL;
+    time1->sec = testTime1SecondsTT;
+    time1->nsec = testTime1NanosecondsTT;
+    time1->type = PS_TIME_TT;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_TAI);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from TT to TAI");
+        return 20;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_TAI);
+        return 7;
+    }
+    // Verify time is TAI as expected
+    if(time2->sec != testTime1SecondsTAI) {
+        psError(PS_ERR_UNKNOWN,true,"TAI seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsTAI);
+        return 21;
+    }
+    if(time2->nsec != testTime1NanosecondsTAI) {
+        psError(PS_ERR_UNKNOWN,true,"TT nanoseconds = %ld not as expected %ld",(long int)time2->nsec,
+                (long int)testTime1NanosecondsTAI);
+        return 22;
+    }
+
+    // Attempt to convert a TT time to UT1
+    time2 = NULL;
+    time1->sec = testTime1SecondsTT;
+    time1->nsec = testTime1NanosecondsTT;
+    time1->type = PS_TIME_TT;
+    time1->leapsecond = false;
+    time2 = psTimeConvert(time1,PS_TIME_UT1);
+    if(time1 != time2) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from TT to UT1");
+        return 9;
+    }
+    // Verify time type
+    if(time2->type != PS_TIME_UT1) {
+        psError(PS_ERR_UNKNOWN,true,"Returned time type %d not as expected %d",
+                time2->type, PS_TIME_UT1);
+        return 7;
+    }
+    // Verify time is UT1 as expected
+    if(time2->sec != testTime1SecondsUT1) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 seconds = %ld not as expected %ld",(long int)time2->sec,
+                (long int)testTime1SecondsUT1);
+        return 9;
+    }
+    if(time2->nsec != testTime1NanosecondsUT1) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 nanoseconds = %d not as expected %d",time2->nsec,
+                testTime1NanosecondsUT1);
+        return 10;
+    }
+
+    // Attempt to convert from UT1 to TAI, UTC, TT
+    time2 = NULL;
+    time1->sec = 1;
+    time1->nsec = 2;
+    time1->type = PS_TIME_UT1;
+    time1->leapsecond = false;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message converting from UT1");
+    time2 = psTimeConvert(time1,PS_TIME_UTC);
+    if(time2 != time1) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return time for conversion from UT1");
+        return 23;
+    }
+
+    psFree(time1);
+
+    return 0;
+}
+
+//psS32 testTimeOther(void)
+//{
+//    psTime *testTime;
+//    char *testString = "2004-07-21T18:22:24.272Z";
+//
+//    psLibInit(true,"psTime.config");
+//
+// Test time was taken at July 21, 2004 at 18:22:24.272044
+//    testTime = (psTime*)psAlloc(sizeof(psTime));
+//    testTime->sec = 1090434144;
+//    testTime->nsec = 272044000;
+//    testTime->type = PS_TIME_TAI;
+
+// Test O - psTime to LMST
+//    printPositiveTestHeader(stdout, "psTime", "Convert psTime time to LST");
+//    char *testString2 = "2004-09-10T1:00:00.00Z";
+//    psTime* testTime2 = NULL;
+//    testTime2 = psTimeFromISO(testString2);
+//    double dblTime = psTimeToLMST(testTime2, 1);
+//    printf("LST (rad): %lf\n", dblTime);
+//    psFree(testTime2);
+//    printFooter(stdout, "psTime", "Convert psTime time to LST", true);
+
+
+//    return 0;
+//}
Index: /trunk/psLib/test/astronomy/tst_psTime_03.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psTime_03.c	(revision 4058)
+++ /trunk/psLib/test/astronomy/tst_psTime_03.c	(revision 4059)
@@ -1,3 +1,2 @@
-
 /** @file  tst_psTime_03.c
  *
@@ -5,20 +4,13 @@
  *
  *  This test driver contains the following tests for psTime:
- *
- *   Test A - Add two times
- *   Test B - Add two times with overflow in microseconds
- *   Test C - Subtact two times
- *   Test D - Subtact two times with underflow in microseconds
- *   Test E - Delta two times
- *   Test F - Delta two times with underflow in microseconds
- *   Test G - Add two times across leapsecond boundary
- *   Test H - Find number of leapseconds added between two times
- *   Test H1 - Verify error message to invalid time type in psTimeAlloc
- *   Test G - Free data
+ *   1) psTimeMath invalid times
+ *   2) psTimeMath valid time of different types
+ *   3) psTimeDelta valid times with different types
  *
  *  @author  Ross Harman, MHPCC
+ *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.16 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-04-19 02:13:53 $
+ *  @version $Revision: 1.17 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-05-31 22:01:27 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -28,191 +20,482 @@
 #include "pslib_strict.h"
 #include "psTest.h"
-
-#define PRINT_TIME(TEXT,TIME) \
-printf("%s Seconds = %lld Nanoseconds = %u\n", TEXT, (long long int)TIME->sec, TIME->nsec);
+#include <string.h>
+
+#define ERROR_TOL    0.001
+
+static psS32 testTimeMath(void);
+static psS32 testTimeDelta(void);
+static psS32 testTimeConvert1(void);
+
+// Test Time 1 : May 9, 2005 00:00:00,0
+//               MJD = 53499.00
+//               JD = 2453499.5
+// UTC Test Time 1
+const psS64 testTime1SecondsUTC         = 1115596900;
+const psU32 testTime1NanosecondsUTC     = 0;
+// TAI Test Time 1
+const psS64 testTime1SecondsTAI         = 1115596932;
+const psU32 testTime1NanosecondsTAI     = 0;
+// TT Test Time 1
+const psS64 testTime1SecondsTT          = 1115596964;
+const psU32 testTime1NanosecondsTT      = 184000000;
+// UT1 Test Time 1
+const psS64 testTime1SecondsUT1         = 1115596900;
+const psU32 testTime1NanosecondsUT1     = 184000000;
+// Delta 1
+const psF64 deltaTime1                  = -15.5;
+// Expected UTC Time 1
+const psS64 newTestTime1SecondsUTC      = 1115596884;
+const psU32 newTestTime1NanosecondsUTC  = 500000000;
+// Expected TAI Time 1
+const psS64 newTestTime1SecondsTAI      = 1115596916;
+const psU32 newTestTime1NanosecondsTAI  = 500000000;
+// Delta 2
+const psF64 deltaTime2                  = 123.066;
+// Expected TT Time 1 w/ delta 2
+const psS64 newTestTime1SecondsTT       = 1115597087;
+const psU32 newTestTime1NanosecondsTT   = 250000000;
+// Expected UT1 Time 1 w/ delta 2
+const psS64 newTestTime1SecondsUT1      = 1115597023;
+const psU32 newTestTime1NanosecondsUT1  = 250000000;
+
+// Test Time 2 : Dec. 31 1998 23:59:45,0
+//               MJD = 51178.99983
+//               JD = 2451179.49983
+// UTC Test Time 1
+const psS64 testTime2SecondsUTC         = 915148785;
+const psU32 testTime2NanosecondsUTC     = 0;
+// Delta 3
+const psF64 deltaTime3                    = 30.0;
+// Expected UTC Time
+const psS64 newTestTime2SecondsUTC      = 915148814;
+const psU32 newTestTime2NanosecondsUTC  = 0;
+
+// Appendix B time conversion tests
+//
+#define APPB_TESTS    8
+const psS64 testTimeBSeconds[APPB_TESTS] =
+    {
+        915148829,
+        915148829,
+        915148830,
+        915148830,
+        915148831,
+        915148831,
+        915148832,
+        915148832
+    };
+const psU32 testTimeBNanoseconds[APPB_TESTS] =
+    {
+        0,
+        500000000,
+        0,
+        500000000,
+        0,
+        500000000,
+        0,
+        500000000
+    };
+const psBool testTimeBLeapsecond[APPB_TESTS] =
+    {
+        false,
+        false,
+        false,
+        false,
+        true,
+        true,
+        false,
+        false
+    };
+// Expected results
+const char* testTimeBStrUTC[APPB_TESTS] =
+    {
+        "1998-12-31T23:59:58,0Z",
+        "1998-12-31T23:59:58,5Z",
+        "1998-12-31T23:59:59,0Z",
+        "1998-12-31T23:59:59,5Z",
+        "1998-12-31T23:59:60,0Z",
+        "1998-12-31T23:59:60,5Z",
+        "1999-01-01T00:00:00,0Z",
+        "1999-01-01T00:00:00,5Z"
+    };
+const char* testTimeBStrTAI[APPB_TESTS] =
+    {
+        "1999-01-01T00:00:29,0Z",
+        "1999-01-01T00:00:29,5Z",
+        "1999-01-01T00:00:30,0Z",
+        "1999-01-01T00:00:30,5Z",
+        "1999-01-01T00:00:31,0Z",
+        "1999-01-01T00:00:31,5Z",
+        "1999-01-01T00:00:32,0Z",
+        "1999-01-01T00:00:32,5Z"
+    };
+const char* testTimeBStrTT[APPB_TESTS] =
+    {
+        "1999-01-01T00:01:01,1Z",
+        "1999-01-01T00:01:01,6Z",
+        "1999-01-01T00:01:02,1Z",
+        "1999-01-01T00:01:02,6Z",
+        "1999-01-01T00:01:03,1Z",
+        "1999-01-01T00:01:03,6Z",
+        "1999-01-01T00:01:04,1Z",
+        "1999-01-01T00:01:04,6Z"
+    };
+const char* testTimeBStrUT1[APPB_TESTS] =
+    {
+        "1998-12-31T23:59:58,7Z",
+        "1998-12-31T23:59:59,2Z",
+        "1998-12-31T23:59:59,7Z",
+        "1998-12-31T23:59:60,2Z",
+        "1998-12-31T23:59:60,7Z",
+        "1999-01-01T00:00:00,2Z",
+        "1999-01-01T00:00:00,7Z",
+        "1999-01-01T00:00:01,2Z"
+    };
+
+// Test Time B1 : Dec 31, 1998 23:59:58,0
+//                MJD = 51178.99998
+//                JD = 2451179.49998
+//const psS64 testTimeB1SecondsUTC        = 915148798;
+//const psU32 testTimeB1NanosecondsUTC    = 0;
+// Expected ISO times
+//const char testTimeB1StrUTC[] = "1998-12-31T23:59:58,0Z";
+//const char testTimeB1StrTAI[] = "1999-01-01T00:00:29,0Z";
+//const char testTimeB1StrTT[]  = "1999-01-01T00:01:01,1Z";
+//const char testTimeB1StrUT1[] = "1998-12-31T23:59:57,7Z";
+//
+// Test Time B2 : Dec 31, 1998 23:59:58,5
+//
+//
+//const psS64 testTimeB2SecondsUTC       = 915148798;
+//const psU32 testTimeB2NanosecondsUTC   = 500000000;
+// Expected ISO times
+//const char testTimeB2StrUTC[] = "1998-12-31T23:59:58,5Z";
+//const char testTimeB2StrTAI[] = "1991-01-01T00:00:29,5Z";
+//const char testTimeB2StrTT[]  = "1999-01-01T00:01:01,6Z";
+//const char testTimeB2StrUT1[] = "1998-12-31T23:59:58,2Z";
+
+testDescription tests[] = {
+                              {testTimeMath,000,"psTimeMath",0,false},
+                              {testTimeDelta,000,"psTimeDelta",0,false},
+                              {testTimeConvert1,000,"psTimeConvert",0,false},
+                              {NULL}
+                          };
 
 psS32 main(psS32 argc, char* argv[])
 {
-
+    psLogSetLevel(PS_LOG_INFO);
+
+    // Initialize library internal structures
     psLibInit(true,"psTime.config");
 
-    // Test A - Add two times
-    printPositiveTestHeader(stdout, "psTime", "Test A - Add two times");
-    psTime *time1a = NULL;
-    psF64 time1b = 1.111111;
-    psTime *timeOut1 = NULL;
-    time1a = psTimeAlloc(PS_TIME_TAI);
-    time1a->sec  = 1;
-    time1a->nsec = 111111000;
-    timeOut1 = psTimeMath(time1a, time1b);
-    if(timeOut1->sec!=2 && timeOut1->nsec!=222222000) {
-        printf("ERROR: Incorrect time, %lld:%u. Expected 2:222222000\n",(long long int)timeOut1->sec, timeOut1->nsec);
-    }
-    printFooter(stdout, "psTime", "Test A - Add two times", true);
-
-
-    // Test B - Add two times with overflow in nanoseconds
-    printPositiveTestHeader(stdout, "psTime", "Test B - Add two times with overflow in microseconds");
-    psTime *time2a = NULL;
-    psF64 time2b = 5.500001;
-    psTime *timeOut2 = NULL;
-    time2a = psTimeAlloc(PS_TIME_TAI);
-    time2a->sec  = 6;
-    time2a->nsec = 600001000;
-    timeOut2 = psTimeMath(time2a, time2b);
-    if(timeOut2->sec!=12 && timeOut2->nsec!=100002000) {
-        printf("ERROR: Incorrect time, %lld:%u. Expected 12:100002000\n",(long long int)timeOut2->sec, timeOut2->nsec);
-    }
-    printFooter(stdout, "psTime", "Test B - Add two times with overflow in microseconds", true);
-
-
-    // Test C - Subtact two times
-    printPositiveTestHeader(stdout, "psTime", "Test C - Subtract two times");
-    psTime *time3a = NULL;
-    psF64 time3b = -1.111111;
-    psTime *timeOut3 = NULL;
-    time3a = psTimeAlloc(PS_TIME_TAI);
-    time3a->sec  = 3;
-    time3a->nsec = 333333000;
-    timeOut3 = psTimeMath(time3a, time3b);
-    if(timeOut3->sec!=2 && timeOut3->nsec!=222222000) {
-        printf("ERROR: Incorrect time, %lld:%u. Expected 2:222222000\n",(long long int)timeOut3->sec, timeOut3->nsec);
-    }
-    printFooter(stdout, "psTime", "Test C - Subtract two times", true);
-
-
-    // Test D - Subtact two times with underflow in nanoseconds
-    printPositiveTestHeader(stdout, "psTime", "Test D - Subtact two times with underflow in nanoseconds");
-    psTime *time4a = NULL;
-    psF64 time4b = -2.000003;
-    psTime *timeOut4 = NULL;
-    time4a = psTimeAlloc(PS_TIME_TAI);
-    time4a->sec  = 5;
-    time4a->nsec = 1000;
-    timeOut4 = psTimeMath(time4a, time4b);
-    if(timeOut4->sec!=2 && timeOut4->nsec!=999997000) {
-        printf("ERROR: Incorrect time, %lld:%u. Expected 2:999997000\n",(long long int)timeOut4->sec, timeOut4->nsec);
-    }
-    printFooter(stdout, "psTime", "Test D - Subtact two times with underflow in nanoseconds", true);
-
-
-    // Test E - Delta two times
-    printPositiveTestHeader(stdout, "psTime", "Test E - Delta two times");
-    psTime *time5a = NULL;
-    psTime *time5b = NULL;
-    psF64 timeOut5 = 0.0;
-    time5a = psTimeAlloc(PS_TIME_TAI);
-    time5b = psTimeAlloc(PS_TIME_TAI);
-    time5a->sec  = 8;
-    time5a->nsec = 8000;
-    time5b->sec  = 7;
-    time5b->nsec = 7000;
-    timeOut5 = psTimeDelta(time5a, time5b);
-    if(fabs(timeOut5-1.000001) > FLT_EPSILON) {
-        printf("ERROR: Incorrect delta, %lf. Expected -1.000001\n", timeOut5);
-    }
-    printFooter(stdout, "psTime", "Test E - Delta two times", true);
-
-
-    // Test F - Delta two times with underflow in microseconds
-    printPositiveTestHeader(stdout, "psTime", "Test F - Delta two times with underflow in microseconds");
-    psTime *time6a = NULL;
-    psTime *time6b = NULL;
-    psF64 timeOut6 = 0.0;
-    time6a = psTimeAlloc(PS_TIME_TAI);
-    time6b = psTimeAlloc(PS_TIME_TAI);
-    time6a->sec  = 8;
-    time6a->nsec = 1000;
-    time6b->sec  = 7;
-    time6b->nsec = 7000;
-    timeOut6 = psTimeDelta(time6a, time6b);
-    if(fabs(timeOut6-0.999994) > FLT_EPSILON) {
-        printf("ERROR: Incorrect delta, %lf. Expected 0.999994\n", timeOut6);
-    }
-    printFooter(stdout, "psTime", "Test F - Delta two times with underflow in microseconds", true);
-
-    // Test F1 - Delta two times in UTC type
-    printPositiveTestHeader(stdout,"psTime","Test F1 - Delta two UTC times");
-    psTime *time20a = NULL;
-    psTime *time20b = NULL;
-    psF64 timeOut20 = 0.0;
-    time20a = psTimeAlloc(PS_TIME_UTC);
-    time20b = psTimeAlloc(PS_TIME_UTC);
-    time20a->sec = 1090434113;
-    time20a->nsec = 272044000;
-    time20b->sec = 1090434112;
-    time20b->nsec = 272044000;
-    timeOut20 = psTimeDelta(time20a, time20b);
-    if(fabs(timeOut20-1.000000000) > FLT_EPSILON) {
-        printf("ERROR: Incorrect delta, %lf. Expected -1.00000\n",timeOut20);
-    }
-    printFooter(stdout,"psTime","Test F1 - Delta two UTC times",true);
-
-    // Test G - Add two times across leapsecond boundary
-    printPositiveTestHeader(stdout, "psTime", "Test G - Add two times across leapsecond boundary");
-    psF64 time7b = 30.0;
-    char *out7 = NULL;
-    psTime *time7a = NULL;
-    psTime *timeOut7 = NULL;
-    time7a = psTimeFromISO("1998-12-31T23:59:45.00");
-    time7a->type = PS_TIME_UTC;
-    timeOut7 = psTimeMath(time7a, time7b);
-    out7 = psTimeToISO(timeOut7);
-    printf("%s\n", out7);
-    printFooter(stdout, "psTime", "Test G - Add two times across leapsecond boundary", true);
-
-
-    // Test H - Find number of leapseconds added between two times
-    printPositiveTestHeader(stdout, "psTime", "Test H - Find number of leapseconds added between two times");
-    psS64 out = 0.0;
-    psTime *time8a = NULL;
-    psTime *time8b = NULL;
-    time8a = psTimeFromISO("2004-12-18T1:00:00.00");
-    time8b = psTimeFromISO("1972-1-1T1:00:00.00");
-    out = psTimeLeapSecondDelta(time8a, time8b);
-    printf("%lld\n", (long long int)out);
-    printFooter(stdout, "psTime", "Test H - Find number of leapseconds added between two times", true);
-
-    // Test H1 - Error in allocating time not UTC or TAI
-    printPositiveTestHeader(stdout,"psTime","Test H1 - Verify error message in allocating invalid time type");
-    psLogMsg(__func__,PS_LOG_INFO,"Invalid time type during allocation should generate error message");
-    psTime *time10 = psTimeAlloc(10);
-    if(time10 != NULL) {
-        printf("ERROR: returned time should be NULL\n");
-    }
-    printFooter(stdout,"psTime","Test H1 - Verify error message in allocating invalid time type",true);
-
-    // Test G - Free data
-    printPositiveTestHeader(stdout, "psTime", "Test I - Free data");
+    if( !runTestSuite(stderr,"psTime",tests,argc,argv)) {
+        return 1;
+    }
+
+    // Clean up library
     psLibFinalize();
-    psFree(time1a);
-    psFree(timeOut1);
-    psFree(time2a);
-    psFree(timeOut2);
-    psFree(time3a);
-    psFree(timeOut3);
-    psFree(time4a);
-    psFree(timeOut4);
-    psFree(time5a);
-    psFree(time5b);
-    psFree(time6a);
-    psFree(time6b);
-    psFree(out7);
-    psFree(time7a);
-    psFree(timeOut7);
-    psFree(time8a);
-    psFree(time8b);
-    psFree(time20a);
-    psFree(time20b);
-    if (psMemCheckLeaks(0, NULL, stdout,false)) {
-        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected.");
-        return 10;
-    }
-    psMemCheckCorruption(0);
-    psS32 nBad = psMemCheckCorruption(0);
-    if(nBad) {
-        printf("ERROR: Found %d bad memory blocks\n", nBad);
-    }
-    printFooter(stdout, "psTime", "Test I - Free data", true);
+
     return 0;
 }
+
+psS32 testTimeMath(void)
+{
+    psTime*     time      = NULL;
+    psTime*     newTime   = NULL;
+
+    // Attempt to perform math operation on NULL time
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL time");
+    if(psTimeMath(time,-1.1) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for NULL time");
+        return 1;
+    }
+
+    // Set up input time with invalid nanoseconds
+    time = psTimeAlloc(PS_TIME_UTC);
+    time->sec = 0;
+    time->nsec = 2e9;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid time");
+    if(psTimeMath(time,-1.1) != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid time");
+        return 2;
+    }
+
+    // Set up input time with valid time
+    time->sec = testTime1SecondsUTC;
+    time->nsec = testTime1NanosecondsUTC;
+    newTime = psTimeMath(time,deltaTime1);
+    if(newTime == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return");
+        return 3;
+    }
+    if(newTime->type != PS_TIME_UTC) {
+        psError(PS_ERR_UNKNOWN,true,"New time type %d not as expected %d",
+                newTime->type,PS_TIME_UTC);
+        return 4;
+    }
+    if((newTime->sec != newTestTime1SecondsUTC) || (newTime->nsec != newTestTime1NanosecondsUTC)) {
+        psError(PS_ERR_UNKNOWN,true,"UTC sec %ld nsec %d not as expected sec %ld nsec %d",
+                (long int)newTime->sec,newTime->nsec,(long int)newTestTime1SecondsUTC,
+                newTestTime1NanosecondsUTC);
+        return 5;
+    }
+    psFree(newTime);
+
+    // Set up input time with valid TAI time
+    time->sec = testTime1SecondsTAI;
+    time->nsec = testTime1NanosecondsTAI;
+    time->type = PS_TIME_TAI;
+    newTime = psTimeMath(time,deltaTime1);
+    if(newTime == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return");
+        return 3;
+    }
+    if(newTime->type != PS_TIME_TAI) {
+        psError(PS_ERR_UNKNOWN,true,"New time type %d not as expected %d",
+                newTime->type,PS_TIME_TAI);
+        return 4;
+    }
+    if((newTime->sec != newTestTime1SecondsTAI) || (newTime->nsec != newTestTime1NanosecondsTAI)) {
+        psError(PS_ERR_UNKNOWN,true,"TAI sec %ld nsec %d not as expected sec %ld nsec %d",
+                (long int)newTime->sec,newTime->nsec,(long int)newTestTime1SecondsTAI,
+                newTestTime1NanosecondsTAI);
+        return 5;
+    }
+    psFree(newTime);
+
+    // Set up input time with valid TT time
+    time->sec = testTime1SecondsTT;
+    time->nsec = testTime1NanosecondsTT;
+    time->type = PS_TIME_TT;
+    newTime = psTimeMath(time,deltaTime2);
+    if(newTime == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return");
+        return 3;
+    }
+    if(newTime->type != PS_TIME_TT) {
+        psError(PS_ERR_UNKNOWN,true,"New time type %d not as expected %d",
+                newTime->type,PS_TIME_TT);
+        return 4;
+    }
+    if((newTime->sec != newTestTime1SecondsTT) || (newTime->nsec != newTestTime1NanosecondsTT)) {
+        psError(PS_ERR_UNKNOWN,true,"TT sec %ld nsec %d not as expected sec %ld nsec %d",
+                (long int)newTime->sec,newTime->nsec,(long int)newTestTime1SecondsTT,
+                newTestTime1NanosecondsTT);
+        return 5;
+    }
+    psFree(newTime);
+
+    // Set up input time with valid TT time
+    time->sec = testTime1SecondsUT1;
+    time->nsec = testTime1NanosecondsUT1;
+    time->type = PS_TIME_UT1;
+    newTime = psTimeMath(time,deltaTime2);
+    if(newTime == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return");
+        return 3;
+    }
+    if(newTime->type != PS_TIME_UT1) {
+        psError(PS_ERR_UNKNOWN,true,"New time type %d not as expected %d",
+                newTime->type,PS_TIME_UT1);
+        return 4;
+    }
+    if((newTime->sec != newTestTime1SecondsUT1) || (newTime->nsec != newTestTime1NanosecondsUT1)) {
+        psError(PS_ERR_UNKNOWN,true,"UT1 sec %ld nsec %d not as expected sec %ld nsec %d",
+                (long int)newTime->sec,newTime->nsec,(long int)newTestTime1SecondsUT1,
+                newTestTime1NanosecondsUT1);
+        return 5;
+    }
+    psFree(newTime);
+
+    // Set up input time with valid UTC time and delt which crosses leap second
+    time->sec = testTime2SecondsUTC;
+    time->nsec = testTime2NanosecondsUTC;
+    time->type = PS_TIME_UTC;
+    newTime = psTimeMath(time,deltaTime3);
+    if(newTime == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return");
+        return 3;
+    }
+    if(newTime->type != PS_TIME_UTC) {
+        psError(PS_ERR_UNKNOWN,true,"New time type %d not as expected %d",
+                newTime->type,PS_TIME_UTC);
+        return 4;
+    }
+    if((newTime->sec != newTestTime2SecondsUTC) || (newTime->nsec != newTestTime2NanosecondsUTC)) {
+        psError(PS_ERR_UNKNOWN,true,"UTC sec %ld nsec %d not as expected sec %ld nsec %d",
+                (long int)newTime->sec,newTime->nsec,(long int)newTestTime2SecondsUTC,
+                newTestTime2NanosecondsUTC);
+        return 5;
+    }
+    psFree(newTime);
+
+    psFree(time);
+
+    return 0;
+}
+
+psS32 testTimeDelta(void)
+{
+    psTime*   time1   = NULL;
+    psTime*   time2   = NULL;
+    psF64     delta   = 0.0;
+
+    // Attempt to get delta with time1 NULL
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL time");
+    delta = psTimeDelta(time1,time2);
+    if(fabs(delta-0.0) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return 0 for NULL time argument");
+        return 1;
+    }
+
+    // Set time 1
+    time1 = psTimeAlloc(PS_TIME_UTC);
+
+    // Attempt to get delta with time2 NULL
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL time");
+    delta = psTimeDelta(time1,time2);
+    if(fabs(delta-0.0) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return 0 for NULL time argument");
+        return 2;
+    }
+
+    // Set time 2
+    time2 = psTimeAlloc(PS_TIME_UTC);
+
+    // Set time1 invalid
+    time1->sec = 0;
+    time1->nsec = 2e9;
+    // Attempt to get delta with time1 invalid
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid time");
+    delta = psTimeDelta(time1,time2);
+    if(fabs(delta-0.0) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return 0 for invalid time argument");
+        return 3;
+    }
+
+    // Set time 1 valid
+    time1->sec = testTime1SecondsUTC;
+    time1->nsec = testTime1NanosecondsUTC;
+
+    // Set time 2 invalid
+    time2->sec = 0;
+    time2->nsec = 2e9;
+    // Attempt to get delta with time2 invalid
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid time");
+    delta = psTimeDelta(time1,time2);
+    if(fabs(delta-0.0) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return 0 for invalid time argument");
+        return 4;
+    }
+
+    // Set time 2 valid but different type
+    time2->sec = newTestTime1SecondsUTC;
+    time2->nsec = newTestTime1NanosecondsUTC;
+    time2->type = PS_TIME_TAI;
+    // Attempt to get delta with different time types
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for incorrect type");
+    delta = psTimeDelta(time1,time2);
+    if(fabs(delta-0.0) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return 0 for invalid time argument");
+        return 5;
+    }
+
+    // Set time 2 to same as time 1
+    time2->type = PS_TIME_UTC;
+    // Attempt to get delta with valid times of the same type
+    delta = psTimeDelta(time2,time1);
+    if(fabs(delta-deltaTime1) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Delta %lf not as expected %lf",
+                delta,deltaTime1);
+        return 6;
+    }
+
+    // Set time 1 and 2 as different times with same type
+    time1->sec = testTime1SecondsTT;
+    time1->nsec = testTime1NanosecondsTT;
+    time1->type = PS_TIME_TT;
+    time2->sec = newTestTime1SecondsTT;
+    time2->nsec = newTestTime1NanosecondsTT;
+    time2->type = PS_TIME_TT;
+    // Attempt to get delta with valid times of the same type
+    delta = psTimeDelta(time2,time1);
+    if(fabs(delta-deltaTime2) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Delta %lf not as expected %lf",
+                delta,deltaTime2);
+        return 7;
+    }
+
+    // Set time 1 and 2 as different times with same type
+    time1->sec = testTime2SecondsUTC;
+    time1->nsec = testTime2NanosecondsUTC;
+    time1->type = PS_TIME_UTC;
+    time2->sec = newTestTime2SecondsUTC;
+    time2->nsec = newTestTime2NanosecondsUTC;
+    time2->type = PS_TIME_UTC;
+    // Attempt to get delta with valid times of the same type
+    delta = psTimeDelta(time2,time1);
+    if(fabs(delta-deltaTime3) > ERROR_TOL) {
+        psError(PS_ERR_UNKNOWN,true,"Delta %lf not as expected %lf",
+                delta,deltaTime3);
+        return 7;
+    }
+
+    psFree(time1);
+    psFree(time2);
+
+    return 0;
+}
+
+psS32 testTimeConvert1(void)
+{
+    psTime*     time    = NULL;
+    char*       timeStr = NULL;
+
+    for(psS32 i = 0; i < APPB_TESTS; i++) {
+
+        // Initialize time for test time B1
+        time = psTimeAlloc(PS_TIME_TAI);
+        time->sec = testTimeBSeconds[i];
+        time->nsec = testTimeBNanoseconds[i];
+
+        // Verify TAI ISO string
+        timeStr = psTimeToISO(time);
+        if(strcmp(timeStr,testTimeBStrTAI[i]) != 0) {
+            psError(PS_ERR_UNKNOWN,true,"TAI ISO string %s not as expected %s",timeStr,testTimeBStrTAI[i]);
+            return i+1;
+        }
+        psFree(timeStr);
+
+        time = psTimeConvert(time,PS_TIME_TT);
+        timeStr = psTimeToISO(time);
+        if(strcmp(timeStr,testTimeBStrTT[i]) != 0) {
+            psError(PS_ERR_UNKNOWN,true,"TT ISO string %s not as expected %s",timeStr,testTimeBStrTT[i]);
+            return i+10;
+        }
+        psFree(timeStr);
+
+        // Verify UTC ISO string
+        time = psTimeConvert(time,PS_TIME_UTC);
+        time->leapsecond = testTimeBLeapsecond[i];
+        timeStr = psTimeToISO(time);
+        if(strcmp(timeStr,testTimeBStrUTC[i]) != 0) {
+            psError(PS_ERR_UNKNOWN,true,"UTC ISO string %s not as expected %s",timeStr,testTimeBStrUTC[i]);
+            return i+20;
+        }
+        psFree(timeStr);
+
+        time = psTimeConvert(time,PS_TIME_UT1);
+        timeStr = psTimeToISO(time);
+        if(strcmp(timeStr,testTimeBStrUT1[i]) != 0) {
+            psError(PS_ERR_UNKNOWN,true,"UT1 ISO string %s not as expected %s",timeStr,testTimeBStrUT1[i]);
+            return i+30;
+        }
+        psFree(timeStr);
+
+        psFree(time);
+    }
+
+    return 0;
+}
+
Index: /trunk/psLib/test/astronomy/tst_psTime_04.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psTime_04.c	(revision 4058)
+++ /trunk/psLib/test/astronomy/tst_psTime_04.c	(revision 4059)
@@ -13,7 +13,8 @@
  *
  *  @author  Ross Harman, MHPCC
+ *  @author  Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.11 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-04-07 20:27:41 $
+ *  @version $Revision: 1.12 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-05-31 22:02:25 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,68 +26,81 @@
 #include "psTest.h"
 
+static psS32 testTimeInit1(void);
+static psS32 testTimeInit2(void);
+static psS32 testTimeInit3(void);
+static psS32 testTimeInit4(void);
+static psS32 testTimeInit5(void);
+static psS32 testTimeInit6(void);
 
-int main(int argc, char* argv[])
+testDescription tests[] = {
+                              {testTimeInit1,000,"p_psTimeInit",0,false},
+                              {testTimeInit2,000,"p_psTimeInit",0,false},
+                              {testTimeInit3,000,"p_psTimeInit",0,false},
+                              {testTimeInit4,000,"p_psTimeInit",0,false},
+                              {testTimeInit5,000,"p_psTimeInit",0,false},
+                              {testTimeInit6,000,"p_psTimeInit",0,false},
+                              {NULL}
+                          };
+
+psS32 main(psS32 argc, char* argv[])
 {
-    // Test A - Initialize time
-    printPositiveTestHeader(stdout, "psTime", "Test A - Initialize time");
-    psLibInit(true, "psTime.config");
-    psLibFinalize();
-    printFooter(stdout, "psTime", "Test A - Initialize time", true);
-
-
-    // Test B - Attempt to open non-existant time config file
-    printNegativeTestHeader(stdout,"psTime", "Test B - Attempt to open non-existant time config file",
-                            "Failed to open file 'zzz'.  Check if it exists and it has the proper permissions.", 0);
-    psLibInit(true, "zzz");
-    printFooter(stdout, "psTime", "Test B - Attempt to open non-existant time config file", true);
-
-
-    // Test C - Attempt to open non-existant time data files
-    printNegativeTestHeader(stdout,"psTime", "Test C - Attempt to open non-existant time data files",
-                            "Failed to open file 'zzz'.  Check if it exists and it has the proper permissions.", 0);
-    psLibInit(true, "test.psTime.config1");
-    psLibFinalize();
-    printFooter(stdout, "psTime", "Test C - Attempt to open non-existant time data files", true);
-
-
-    // Test D - Attempt to read incorrect number of files
-    printNegativeTestHeader(stdout,"psTime", "Test D - Attempt to read incorrect number of files",
-                            "Incorrect number of table files entered. Found: 3. Expected: 4.", 0);
-    psLibInit(true, "test.psTime.config2");
-    psLibFinalize();
-    printFooter(stdout, "psTime", "Test D - Attempt to read incorrect number of files", true);
-
-
-    // Test E - Attempt to read incorrect number of from values
-    printNegativeTestHeader(stdout,"psTime", "Test E - Attempt to read incorrect number of from values",
-                            "Incorrect vector size. Size: 3, Expected 4.", 0);
-    psLibInit(true, "test.psTime.config3");
-    psLibFinalize();
-    printFooter(stdout, "psTime", "Test E - Attempt to read incorrect number of from values", true);
-
-
-    // Test F - Attempt to read data file with typo in number
-    printNegativeTestHeader(stdout,"psTime", "Test F - Attempt to read data file with typo in number",
-                            "Unable to parse string, number on line 16.", 0);
-    psLibInit(true, "test.psTime.config4");
-    psLibFinalize();
-    printFooter(stdout, "psTime", "Test F - Attempt to read data file with typo in number", true);
-
-
-    // Test G - Free data
-    printPositiveTestHeader(stdout, "psTime", "Test G - Free data");
-    psLibFinalize();
-    if( psMemCheckLeaks(0, NULL, stdout,false) != 0 ) {
-        psError(PS_ERR_UNKNOWN,true,"Memory leak detected.");
-        return 10;
+    if(!runTestSuite(stderr,"psTime",tests,argc,argv)) {
+        return 1;
     }
-    psMemCheckCorruption(0);
-    int nBad = psMemCheckCorruption(0);
-    if(nBad) {
-        printf("ERROR: Found %d bad memory blocks\n", nBad);
-    }
-    printFooter(stdout, "psTime", "Test G - Free data", true);
 
     return 0;
 }
 
+psS32 testTimeInit1(void)
+{
+    // Test A - Initialize time
+    psLibInit(true, "psTime.config");
+    psLibFinalize();
+
+    return 0;
+}
+
+psS32 testTimeInit2(void)
+{
+    // Test B - Attempt to open non-existant time config file
+    psLibInit(true, "zzz");
+
+    return 0;
+}
+
+psS32 testTimeInit3(void)
+{
+    // Test C - Attempt to open non-existant time data files
+    psLibInit(true, "test.psTime.config1");
+    psLibFinalize();
+
+    return 0;
+}
+
+psS32 testTimeInit4(void)
+{
+    // Test D - Attempt to read incorrect number of files
+    psLibInit(true, "test.psTime.config2");
+    psLibFinalize();
+
+    return 0;
+}
+
+psS32 testTimeInit5(void)
+{
+    // Test E - Attempt to read incorrect number of from values
+    psLibInit(true, "test.psTime.config3");
+    psLibFinalize();
+
+    return 0;
+}
+
+psS32 testTimeInit6(void)
+{
+    // Test F - Attempt to read data file with typo in number
+    psLibInit(true, "test.psTime.config4");
+    psLibFinalize();
+
+    return 0;
+}
+
Index: /trunk/psLib/test/astronomy/verified/tst_psTime_01.stderr
===================================================================
--- /trunk/psLib/test/astronomy/verified/tst_psTime_01.stderr	(revision 4059)
+++ /trunk/psLib/test/astronomy/verified/tst_psTime_01.stderr	(revision 4059)
@@ -0,0 +1,241 @@
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeAlloc}                                        *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeAlloc
+    Following should generate error message
+<DATE><TIME>|<HOST>|E|psTimeAlloc (FILE:LINENO)
+    Specified type, -100, is not supported.
+
+---> TESTPOINT PASSED (psTime{psTimeAlloc} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeGetNow}                                       *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeGetNow
+    Following should generate an error message for invalid time type
+<DATE><TIME>|<HOST>|E|psTimeAlloc (FILE:LINENO)
+    Specified type, -100, is not supported.
+
+---> TESTPOINT PASSED (psTime{psTimeGetNow} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeGetUT1Delta}                                  *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeGetUT1Delta
+    Following should generate an error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeGetUT1Delta (FILE:LINENO)
+    Unallowable operation: time is NULL.
+<DATE><TIME>|<HOST>|I|testTimeGetUT1Delta
+    Following should generate an error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeGetUT1Delta (FILE:LINENO)
+    Error: time->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+<DATE><TIME>|<HOST>|I|testTimeGetUT1Delta
+    Following should generate an error message for invalid bulletin
+<DATE><TIME>|<HOST>|E|psTimeGetUT1Delta (FILE:LINENO)
+    Invalid bulletin specified -100
+<DATE><TIME>|<HOST>|I|testTimeGetUT1Delta
+    Following should generate a warning message predating table
+<DATE><TIME>|<HOST>|W|psTimeGetUT1Delta
+    Specified psTime predates (41683) all tables of UT1-UTC information.
+<DATE><TIME>|<HOST>|I|testTimeGetUT1Delta
+    Following should generate a warning message predating table
+<DATE><TIME>|<HOST>|W|psTimeGetUT1Delta
+    Specified psTime predates (41683) all tables of UT1-UTC information.
+<DATE><TIME>|<HOST>|I|testTimeGetUT1Delta
+    Following should generate a warning message postdating table
+<DATE><TIME>|<HOST>|W|psTimeGetUT1Delta
+    Specified psTime postdates (53999) all tables of UT1-UTC information.
+<DATE><TIME>|<HOST>|I|testTimeGetUT1Delta
+    Following should generate a warning message postdating table
+<DATE><TIME>|<HOST>|W|psTimeGetUT1Delta
+    Specified psTime postdates (53999) all tables of UT1-UTC information.
+
+---> TESTPOINT PASSED (psTime{psTimeGetUT1Delta} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeToMJD}                                        *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeToMJD
+    Following should generate an error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeToMJD (FILE:LINENO)
+    Unallowable operation: time is NULL.
+<DATE><TIME>|<HOST>|I|testTimeToMJD
+    Following should generate an error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeToMJD (FILE:LINENO)
+    Error: time->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+
+---> TESTPOINT PASSED (psTime{psTimeToMJD} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeToJD}                                         *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeToJD
+    Following should generate an error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeToJD (FILE:LINENO)
+    Unallowable operation: time is NULL.
+<DATE><TIME>|<HOST>|I|testTimeToJD
+    Following should generate an error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeToJD (FILE:LINENO)
+    Error: time->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+
+---> TESTPOINT PASSED (psTime{psTimeToJD} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeToISO}                                        *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeToISO
+    Following should generate error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeToISO (FILE:LINENO)
+    Unallowable operation: time is NULL.
+<DATE><TIME>|<HOST>|I|testTimeToISO
+    Following should generate an error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeToISO (FILE:LINENO)
+    Error: time->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+<DATE><TIME>|<HOST>|I|testTimeToISO
+    Following should generate error message for time prior year 0000
+<DATE><TIME>|<HOST>|E|psTimeToISO (FILE:LINENO)
+    Error: time->sec, -62125920001, is out of range.
+<DATE><TIME>|<HOST>|I|testTimeToISO
+    Following should generate error message for time after year 9999
+<DATE><TIME>|<HOST>|E|psTimeToISO (FILE:LINENO)
+    Error: time->sec, 253202544001, is out of range.
+
+---> TESTPOINT PASSED (psTime{psTimeToISO} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeToTimeval}                                    *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeToTimeval
+    Following should generate error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeToTimeval (FILE:LINENO)
+    Unallowable operation: time is NULL.
+<DATE><TIME>|<HOST>|I|testTimeToTimeval
+    Following should generate an error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeToTimeval (FILE:LINENO)
+    Error: time->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+<DATE><TIME>|<HOST>|I|testTimeToTimeval
+    Following should generate an error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeToTimeval (FILE:LINENO)
+    Error: time->sec, -1, is out of range.  Must be between 0 and 2147483647.
+
+---> TESTPOINT PASSED (psTime{psTimeToTimeval} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeFromMJD}                                      *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psTime{psTimeFromMJD} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeFromJD}                                       *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psTime{psTimeFromJD} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeFromISO}                                      *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeFromISO
+    Following should generate error message for NULL ISO string
+<DATE><TIME>|<HOST>|E|psTimeFromISO (FILE:LINENO)
+    Unallowable operation: time is NULL.
+<DATE><TIME>|<HOST>|I|testTimeFromISO
+    Following should generate an error for invalid ISO string
+<DATE><TIME>|<HOST>|E|psTimeFromISO (FILE:LINENO)
+    Specified ISO Time string, 'Here I am', is malformed.  Must be in 'YYYY-MM-DDThh:mm:ss.sss' format.
+
+---> TESTPOINT PASSED (psTime{psTimeFromISO} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeFromTimeval}                                  *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeFromTimeval
+    Following should generate error message for NULL timeval
+<DATE><TIME>|<HOST>|E|psTimeFromTimeval (FILE:LINENO)
+    Unallowable operation: time is NULL.
+
+---> TESTPOINT PASSED (psTime{psTimeFromTimeval} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{p_psTimeFromTM}                                     *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeFromTM
+    Following should generate error message for NULL tm ptr
+<DATE><TIME>|<HOST>|E|p_psTimeFromTM (FILE:LINENO)
+    Unallowable operation: time is NULL.
+
+---> TESTPOINT PASSED (psTime{p_psTimeFromTM} | tst_psTime_01.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_01.c                                            *
+*            TestPoint: psTime{psTimeConvert}                                      *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeConvert
+    Following should generate an error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeConvert (FILE:LINENO)
+    Unallowable operation: time is NULL.
+<DATE><TIME>|<HOST>|I|testTimeConvert
+    Following should generate an error message for invalid type
+<DATE><TIME>|<HOST>|E|psTimeConvert (FILE:LINENO)
+    Specified type, -100, is not supported.
+<DATE><TIME>|<HOST>|I|testTimeConvert
+    Following should generate an error message for invalid type
+<DATE><TIME>|<HOST>|E|psTimeConvert (FILE:LINENO)
+    Specified type, -100, is not supported.
+<DATE><TIME>|<HOST>|I|testTimeConvert
+    Following should generate an error message for invalid type
+<DATE><TIME>|<HOST>|E|psTimeConvert (FILE:LINENO)
+    Specified type, -100, is not supported.
+<DATE><TIME>|<HOST>|I|testTimeConvert
+    Following should generate an error message for invalid type
+<DATE><TIME>|<HOST>|E|psTimeConvert (FILE:LINENO)
+    Specified type, -100, is not supported.
+<DATE><TIME>|<HOST>|I|testTimeConvert
+    Following should generate an error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeConvert (FILE:LINENO)
+    Error: time->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+<DATE><TIME>|<HOST>|I|testTimeConvert
+    Following should generate an error message converting from UT1
+<DATE><TIME>|<HOST>|E|psTimeConvert (FILE:LINENO)
+    Cannot convert from UT1 time type
+
+---> TESTPOINT PASSED (psTime{psTimeConvert} | tst_psTime_01.c)
+
Index: /trunk/psLib/test/astronomy/verified/tst_psTime_01.stdout
===================================================================
--- /trunk/psLib/test/astronomy/verified/tst_psTime_01.stdout	(revision 4058)
+++ /trunk/psLib/test/astronomy/verified/tst_psTime_01.stdout	(revision 4059)
@@ -1,164 +1,0 @@
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Get current TAI time}                               *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Get current TAI time} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Print test time}                                    *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-Test time: Seconds = 1090434144 Nanoseconds = 272044000
-
----> TESTPOINT PASSED (psTime{Print test time} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert psTime to ISO time}                         *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-2004-07-21T<DATE>.272Z
-
----> TESTPOINT PASSED (psTime{Convert psTime to ISO time} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert ISO time to psTime}                         *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-psTime: Seconds = 1090434144 Nanoseconds = 272000000
-
----> TESTPOINT PASSED (psTime{Convert ISO time to psTime} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert psTime time to UTC time}                    *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-psTime: Seconds = 1090434112 Nanoseconds = 272044000
-
----> TESTPOINT PASSED (psTime{Convert psTime time to UTC time} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert UTC time to psTime}                         *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-psTime: Seconds = 1090434144 Nanoseconds = 272044000
-
----> TESTPOINT PASSED (psTime{Convert UTC time to psTime} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert psTime to MJD time}                         *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-MJD = 53207.765559
-
----> TESTPOINT PASSED (psTime{Convert psTime to MJD time} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert MJD time to psTime}                         *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-psTime: Seconds = 1090434144 Nanoseconds = 272043704
-
----> TESTPOINT PASSED (psTime{Convert MJD time to psTime} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert psTime to JD time}                          *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-JD = 2453208.265559
-
----> TESTPOINT PASSED (psTime{Convert psTime to JD time} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert JD time to psTime}                          *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-psTime: Seconds = 1090434144 Nanoseconds = 272048711
-
----> TESTPOINT PASSED (psTime{Convert JD time to psTime} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert psTime to timeval time}                     *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-timevalTime: Seconds = 1090434144 Microseconds = 272044
-
----> TESTPOINT PASSED (psTime{Convert psTime to timeval time} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert timeval time to psTime}                     *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-psTime: Seconds = 1090434144 Nanoseconds = 272044000
-
----> TESTPOINT PASSED (psTime{Convert timeval time to psTime} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert psTime to tm time}                          *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-tmTime:
-tmTime->tm_year = 104
-tmTime->tm_mon = 6
-tmTime->tm_mday = 21
-tmTime->tm_hour = 18
-tmTime->tm_min = 22
-tmTime->tm_sec = 24
-
----> TESTPOINT PASSED (psTime{Convert psTime to tm time} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert tm time to psTime}                          *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-psTime: Seconds = 1090434144 Nanoseconds = 0
-
----> TESTPOINT PASSED (psTime{Convert tm time to psTime} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psTime{Convert psTime time to LST}                         *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-LST (rad): 1.074588
-
----> TESTPOINT PASSED (psTime{Convert psTime time to LST} | tst_psTime_01.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_01.c                                            *
-*            TestPoint: psMetadata{Test P - Free data}                             *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psMetadata{Test P - Free data} | tst_psTime_01.c)
-
Index: /trunk/psLib/test/astronomy/verified/tst_psTime_03.stderr
===================================================================
--- /trunk/psLib/test/astronomy/verified/tst_psTime_03.stderr	(revision 4058)
+++ /trunk/psLib/test/astronomy/verified/tst_psTime_03.stderr	(revision 4059)
@@ -1,4 +1,55 @@
-<DATE><TIME>|<HOST>|I|main
-    Invalid time type during allocation should generate error message
-<DATE><TIME>|<HOST>|E|psTimeAlloc (FILE:LINENO)
-    Specified type, 10, is not supported.
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_03.c                                            *
+*            TestPoint: psTime{psTimeMath}                                         *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeMath
+    Following should generate error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeMath (FILE:LINENO)
+    Unallowable operation: time is NULL.
+<DATE><TIME>|<HOST>|I|testTimeMath
+    Following should generate error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeMath (FILE:LINENO)
+    Error: time->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+
+---> TESTPOINT PASSED (psTime{psTimeMath} | tst_psTime_03.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_03.c                                            *
+*            TestPoint: psTime{psTimeDelta}                                        *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testTimeDelta
+    Following should generate error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeDelta (FILE:LINENO)
+    Unallowable operation: time1 is NULL.
+<DATE><TIME>|<HOST>|I|testTimeDelta
+    Following should generate error message for NULL time
+<DATE><TIME>|<HOST>|E|psTimeDelta (FILE:LINENO)
+    Unallowable operation: time2 is NULL.
+<DATE><TIME>|<HOST>|I|testTimeDelta
+    Following should generate error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeDelta (FILE:LINENO)
+    Error: time1->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+<DATE><TIME>|<HOST>|I|testTimeDelta
+    Following should generate error message for invalid time
+<DATE><TIME>|<HOST>|E|psTimeDelta (FILE:LINENO)
+    Error: time2->nsec, 2000000000, is out of range.  Must be between 0 and 999999999.
+<DATE><TIME>|<HOST>|I|testTimeDelta
+    Following should generate error message for incorrect type
+<DATE><TIME>|<HOST>|E|psTimeDelta (FILE:LINENO)
+    Specified type, 1, is incorrect.
+
+---> TESTPOINT PASSED (psTime{psTimeDelta} | tst_psTime_03.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_03.c                                            *
+*            TestPoint: psTime{psTimeConvert}                                      *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psTime{psTimeConvert} | tst_psTime_03.c)
+
Index: /trunk/psLib/test/astronomy/verified/tst_psTime_03.stdout
===================================================================
--- /trunk/psLib/test/astronomy/verified/tst_psTime_03.stdout	(revision 4058)
+++ /trunk/psLib/test/astronomy/verified/tst_psTime_03.stdout	(revision 4059)
@@ -1,101 +1,0 @@
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test A - Add two times}                             *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test A - Add two times} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test B - Add two times with overflow in microseconds} *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test B - Add two times with overflow in microseconds} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test C - Subtract two times}                        *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test C - Subtract two times} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test D - Subtact two times with underflow in nanoseconds} *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test D - Subtact two times with underflow in nanoseconds} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test E - Delta two times}                           *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test E - Delta two times} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test F - Delta two times with underflow in microseconds} *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test F - Delta two times with underflow in microseconds} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test F1 - Delta two UTC times}                      *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test F1 - Delta two UTC times} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test G - Add two times across leapsecond boundary}  *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-1999-01-01T<DATE>.000Z
-
----> TESTPOINT PASSED (psTime{Test G - Add two times across leapsecond boundary} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test H - Find number of leapseconds added between two times} *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-22
-
----> TESTPOINT PASSED (psTime{Test H - Find number of leapseconds added between two times} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test H1 - Verify error message in allocating invalid time type} *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test H1 - Verify error message in allocating invalid time type} | tst_psTime_03.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test I - Free data}                                 *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test I - Free data} | tst_psTime_03.c)
-
Index: /trunk/psLib/test/astronomy/verified/tst_psTime_04.stderr
===================================================================
--- /trunk/psLib/test/astronomy/verified/tst_psTime_04.stderr	(revision 4058)
+++ /trunk/psLib/test/astronomy/verified/tst_psTime_04.stderr	(revision 4059)
@@ -1,22 +1,74 @@
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_04.c                                            *
+*            TestPoint: psTime{p_psTimeInit}                                       *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+
+---> TESTPOINT PASSED (psTime{p_psTimeInit} | tst_psTime_04.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_04.c                                            *
+*            TestPoint: psTime{p_psTimeInit}                                       *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
 <DATE><TIME>|<HOST>|E|psMetadataParseConfig (FILE:LINENO)
     Failed to open file 'zzz'. Check if it exists and it has the proper permissions.
 <DATE><TIME>|<HOST>|E|psLibInit (FILE:LINENO)
     Failed to initialize psTime.
-<DATE><TIME>|<HOST>|E|psLookupTableRead (FILE:LINENO)
-    Failed to open file bogus/ser7.dat.
-<DATE><TIME>|<HOST>|E|psLookupTableRead (FILE:LINENO)
-    Failed to open file bogus/eopc01_1900_2004.dat.
-<DATE><TIME>|<HOST>|E|psLookupTableRead (FILE:LINENO)
-    Failed to open file bogus/finals_all.dat.
-<DATE><TIME>|<HOST>|E|psLookupTableRead (FILE:LINENO)
-    Failed to open file bogus/tai_utc.dat.
+
+---> TESTPOINT PASSED (psTime{p_psTimeInit} | tst_psTime_04.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_04.c                                            *
+*            TestPoint: psTime{p_psTimeInit}                                       *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
 <DATE><TIME>|<HOST>|E|p_psTimeInit (FILE:LINENO)
-    Incorrect number of table files entered. Found: 3. Expected: 4.
+    Failed find 'psLib.time.tables.index' in time metadata.
+<DATE><TIME>|<HOST>|E|psLibInit (FILE:LINENO)
+    Failed to initialize psTime.
+
+---> TESTPOINT PASSED (psTime{p_psTimeInit} | tst_psTime_04.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_04.c                                            *
+*            TestPoint: psTime{p_psTimeInit}                                       *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|E|p_psTimeInit (FILE:LINENO)
+    Failed find 'psLib.time.tables.index' in time metadata.
+<DATE><TIME>|<HOST>|E|psLibInit (FILE:LINENO)
+    Failed to initialize psTime.
+
+---> TESTPOINT PASSED (psTime{p_psTimeInit} | tst_psTime_04.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_04.c                                            *
+*            TestPoint: psTime{p_psTimeInit}                                       *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
 <DATE><TIME>|<HOST>|E|p_psTimeInit (FILE:LINENO)
     Incorrect vector size. Size: 3, Expected 4.
 <DATE><TIME>|<HOST>|E|psLibInit (FILE:LINENO)
     Failed to initialize psTime.
-<DATE><TIME>|<HOST>|E|printError (FILE:LINENO)
-    Unable to parse string, 53yyy244 on line 16.
-<DATE><TIME>|<HOST>|E|psLookupTableRead (FILE:LINENO)
-    Lookup table is invalid.
+
+---> TESTPOINT PASSED (psTime{p_psTimeInit} | tst_psTime_04.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psTime_04.c                                            *
+*            TestPoint: psTime{p_psTimeInit}                                       *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|E|p_psTimeInit (FILE:LINENO)
+    Failed find 'psLib.time.tables.index' in time metadata.
+<DATE><TIME>|<HOST>|E|psLibInit (FILE:LINENO)
+    Failed to initialize psTime.
+
+---> TESTPOINT PASSED (psTime{p_psTimeInit} | tst_psTime_04.c)
+
Index: /trunk/psLib/test/astronomy/verified/tst_psTime_04.stdout
===================================================================
--- /trunk/psLib/test/astronomy/verified/tst_psTime_04.stdout	(revision 4058)
+++ /trunk/psLib/test/astronomy/verified/tst_psTime_04.stdout	(revision 4059)
@@ -1,73 +1,0 @@
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_04.c                                            *
-*            TestPoint: psTime{Test A - Initialize time}                           *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test A - Initialize time} | tst_psTime_04.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_04.c                                            *
-*            TestPoint: psTime{Test B - Attempt to open non-existant time config file} *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Failed to open file 'zzz'.  Check if it exists and it has the proper permissions. *
-*  ExpectedStatusValue: 0                                                          *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test B - Attempt to open non-existant time config file} | tst_psTime_04.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_04.c                                            *
-*            TestPoint: psTime{Test C - Attempt to open non-existant time data files} *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Failed to open file 'zzz'.  Check if it exists and it has the proper permissions. *
-*  ExpectedStatusValue: 0                                                          *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test C - Attempt to open non-existant time data files} | tst_psTime_04.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_04.c                                            *
-*            TestPoint: psTime{Test D - Attempt to read incorrect number of files} *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Incorrect number of table files entered. Found: 3. Expected: 4. *
-*  ExpectedStatusValue: 0                                                          *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test D - Attempt to read incorrect number of files} | tst_psTime_04.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_04.c                                            *
-*            TestPoint: psTime{Test E - Attempt to read incorrect number of from values} *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Incorrect vector size. Size: 3, Expected 4.                *
-*  ExpectedStatusValue: 0                                                          *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test E - Attempt to read incorrect number of from values} | tst_psTime_04.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_04.c                                            *
-*            TestPoint: psTime{Test F - Attempt to read data file with typo in number} *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Unable to parse string, number on line 16.                 *
-*  ExpectedStatusValue: 0                                                          *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test F - Attempt to read data file with typo in number} | tst_psTime_04.c)
-
-/***************************** TESTPOINT ******************************************\
-*             TestFile: tst_psTime_04.c                                            *
-*            TestPoint: psTime{Test G - Free data}                                 *
-*             TestType: Positive                                                   *
-\**********************************************************************************/
-
-
----> TESTPOINT PASSED (psTime{Test G - Free data} | tst_psTime_04.c)
-
