Index: /trunk/psLib/src/astro/psTime.c
===================================================================
--- /trunk/psLib/src/astro/psTime.c	(revision 3711)
+++ /trunk/psLib/src/astro/psTime.c	(revision 3712)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 00:17:05 $
+ *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 02:13:53 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -64,5 +64,5 @@
 
                 /** Microseconds per day */
-                #define USEC_PER_DAY 86400000000.0
+                #define NSEC_PER_DAY 86400000000000.0
 
                 /** Time metadata read from config file */
@@ -363,6 +363,7 @@
 
     outTime->sec = 0;
-    outTime->usec = 0;
+    outTime->nsec = 0;
     outTime->type = type;
+    outTime->leapsecond = false;
 
     return outTime;
@@ -386,5 +387,5 @@
     // Convert timeval time to psTime
     time->sec = now.tv_sec;
-    time->usec = now.tv_usec;
+    time->nsec = now.tv_usec*1000;
 
     // Add most leapseconds to UTC time to get TAI time if necessary
@@ -403,5 +404,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     if (time->type == type) { // time already right type.  That was easy!
@@ -448,5 +449,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     // Calculate TAI or UTC time based on type of time user passes
@@ -455,10 +456,10 @@
         utcTime = psTimeAlloc(PS_TIME_UTC);
         utcTime->sec = taiTime->sec - psTimeGetTAIDelta(time);
-        utcTime->usec = taiTime->usec;
+        utcTime->nsec = taiTime->nsec;
     } else if(time->type == PS_TIME_UTC) {
         utcTime = psMemIncrRefCounter(time);
         taiTime = psTimeAlloc(PS_TIME_TAI);
         taiTime->sec = utcTime->sec + psTimeGetTAIDelta(time);
-        taiTime->usec = utcTime->usec;
+        taiTime->nsec = utcTime->nsec;
     }
 
@@ -519,5 +520,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     if(time->type != PS_TIME_TAI) {
@@ -592,5 +593,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     if(time->type != PS_TIME_TAI)
@@ -715,5 +716,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     // Check time metadata
@@ -768,6 +769,6 @@
     PS_PTR_CHECK_NULL(time1,0);
     PS_PTR_CHECK_NULL(time2,0);
-    PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0);
-    PS_INT_CHECK_RANGE(time2->usec,0,1e6-1,0);
+    PS_INT_CHECK_RANGE(time1->nsec,0,1e9-1,0);
+    PS_INT_CHECK_RANGE(time2->nsec,0,1e9-1,0);
     diff = abs((psS64)psTimeGetTAIDelta((psTime*)time1)-(psS64)psTimeGetTAIDelta((psTime*)time2));
 
@@ -781,11 +782,11 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     // Julian date conversion
     if(time->sec < 0) {
-        jd = time->sec / SEC_PER_DAY - time->usec / USEC_PER_DAY + 2440587.5; // psTime earlier than epoch
+        jd = time->sec / SEC_PER_DAY - time->nsec / NSEC_PER_DAY + 2440587.5; // psTime earlier than epoch
     } else {
-        jd = time->sec / SEC_PER_DAY + time->usec / USEC_PER_DAY + 2440587.5; // psTime greater than epoch
+        jd = time->sec / SEC_PER_DAY + time->nsec / NSEC_PER_DAY + 2440587.5; // psTime greater than epoch
     }
 
@@ -800,11 +801,11 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     // Modified Julian date conversion
     if(time->sec < 0) {
-        mjd = time->sec / SEC_PER_DAY - time->usec / USEC_PER_DAY + 40587.0; // psTime earlier than epoch
+        mjd = time->sec / SEC_PER_DAY - time->nsec / NSEC_PER_DAY + 40587.0; // psTime earlier than epoch
     } else {
-        mjd = time->sec / SEC_PER_DAY + time->usec / USEC_PER_DAY + 40587.0; // psTime greater than epoch
+        mjd = time->sec / SEC_PER_DAY + time->nsec / NSEC_PER_DAY + 40587.0; // psTime greater than epoch
     }
 
@@ -823,10 +824,10 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     tempString = psAlloc(MAX_TIME_STRING_LENGTH);
     timeString = psAlloc(MAX_TIME_STRING_LENGTH);
 
-    ms = time->usec / 1000;
+    ms = time->nsec / 1000000;
     sec = time->sec;
 
@@ -856,8 +857,8 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,timevalTime);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,timevalTime);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,timevalTime);
 
     timevalTime.tv_sec = time->sec;
-    timevalTime.tv_usec = time->usec;
+    timevalTime.tv_usec = time->nsec / 1000;
 
     return timevalTime;
@@ -879,5 +880,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     seconds = time->sec%60;
@@ -941,12 +942,12 @@
     seconds = days * SEC_PER_DAY;
     if(seconds < 0.0) {
-        outTime->usec = (seconds - (psS64)seconds) * -1000000.0;  // psTime earlier than epoch
+        outTime->nsec = (seconds - (psS64)seconds) * -1000000000.0;  // psTime earlier than epoch
     } else {
-        outTime->usec = (seconds - (psS64)seconds) * 1000000.0;   // psTime greater than epoch
+        outTime->nsec = (seconds - (psS64)seconds) * 1000000000.0;   // psTime greater than epoch
     }
     outTime->sec = seconds;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     return outTime;
@@ -967,12 +968,12 @@
     seconds = days * SEC_PER_DAY;
     if(seconds < 0.0) {
-        outTime->usec = (seconds - (psS64)seconds) * -1000000.0;  // psTime earlier than epoch
+        outTime->nsec = (seconds - (psS64)seconds) * -1000000000.0;  // psTime earlier than epoch
     } else {
-        outTime->usec = (seconds - (psS64)seconds) * 1000000.0;   // psTime greater than epoch
+        outTime->nsec = (seconds - (psS64)seconds) * 1000000000.0;   // psTime greater than epoch
     }
     outTime->sec = seconds;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     return outTime;
@@ -1006,5 +1007,5 @@
     // Convert tm time to psTime
     outTime = psTimeFromTM(&tmTime);
-    outTime->usec = millisecond * 1000;
+    outTime->nsec = millisecond * 1000000;
 
     return outTime;
@@ -1024,8 +1025,8 @@
     // Convert to psTime
     outTime->sec = time->tv_sec;
-    outTime->usec = time->tv_usec;
+    outTime->nsec = time->tv_usec * 1000;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     return outTime;
@@ -1083,8 +1084,8 @@
 
     // C's TM does not define a microsecond field. Microseconds must be manipulated by calling function.
-    outTime->usec = 0;
+    outTime->nsec = 0;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     return outTime;
@@ -1100,5 +1101,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     // Convert time to TAI if necessary, but without changing input arguments
@@ -1106,5 +1107,5 @@
         tempTime = psTimeAlloc(PS_TIME_UTC);
         tempTime->sec = time->sec;
-        tempTime->usec = time->usec;
+        tempTime->nsec = time->nsec;
         tempTime = psTimeConvert(tempTime, PS_TIME_TAI);
     } else {
@@ -1114,10 +1115,10 @@
     // Create output time
     outTime = psTimeAlloc(PS_TIME_TAI);
-    sec = delta + (psF64)tempTime->sec + (psF64)tempTime->usec/1e6;
+    sec = delta + (psF64)tempTime->sec + (psF64)tempTime->nsec/1e9;
     outTime->sec = sec;
-    outTime->usec = (sec - outTime->sec)*1e6;
+    outTime->nsec = (sec - outTime->sec)*1e9;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     // Convert result to same time type as input
@@ -1142,7 +1143,7 @@
     // Error checks
     PS_PTR_CHECK_NULL(time1,0.0);
-    PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0.0);
+    PS_INT_CHECK_RANGE(time1->nsec,0,1e9-1,0.0);
     PS_PTR_CHECK_NULL(time2,0.0);
-    PS_INT_CHECK_RANGE(time2->usec,0,1e6-1,0.0);
+    PS_INT_CHECK_RANGE(time2->nsec,0,1e9-1,0.0);
 
     // Convert time to TAI if necessary, but without changing input arguments
@@ -1150,5 +1151,5 @@
         tempTime1 = psTimeAlloc(PS_TIME_UTC);
         tempTime1->sec = time1->sec;
-        tempTime1->usec = time1->usec;
+        tempTime1->nsec = time1->nsec;
         tempTime1 = psTimeConvert(tempTime1, PS_TIME_TAI);
     } else {
@@ -1158,5 +1159,5 @@
         tempTime2 = psTimeAlloc(PS_TIME_UTC);
         tempTime2->sec = time2->sec;
-        tempTime2->usec = time2->usec;
+        tempTime2->nsec = time2->nsec;
         tempTime2 = psTimeConvert(tempTime2, PS_TIME_TAI);
     } else {
@@ -1165,7 +1166,7 @@
 
     uSec1 = tempTime1->sec >= 0 ? 1.0 : -1.0;
-    uSec1 = uSec1*tempTime1->usec/1e6;
+    uSec1 = uSec1*tempTime1->nsec/1e9;
     uSec2 = tempTime2->sec >= 0 ? 1.0 : -1.0;
-    uSec2 = uSec2*tempTime2->usec/1e6;
+    uSec2 = uSec2*tempTime2->nsec/1e9;
     out = (tempTime1->sec-tempTime2->sec) + (uSec1-uSec2);
 
Index: /trunk/psLib/src/astro/psTime.h
===================================================================
--- /trunk/psLib/src/astro/psTime.h	(revision 3711)
+++ /trunk/psLib/src/astro/psTime.h	(revision 3712)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 00:17:05 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 02:13:53 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -40,4 +40,6 @@
     PS_TIME_TAI,        ///< Temps Atomique International (TAI) time (time with leapseconds).
     PS_TIME_UTC,        ///< Universal Time Coordinated (UTC) time (time without leapseconds).
+    PS_TIME_UT1,        ///< Universal Time corrected for polar motion
+    PS_TIME_TT,         ///< Terrestrial Time
 } psTimeType;
 
@@ -52,5 +54,6 @@
 {
     psS64 sec;          ///< Seconds since epoch, Jan 1, 1970.
-    psU32 usec;         ///< Microseconds since last second.
+    psU32 nsec;         ///< Nanoseconds since last second.
+    psBool leapsecond;  ///< if time falls on UTC leapsecond
     psTimeType type;    ///< Type of time.
 }
Index: /trunk/psLib/src/astronomy/psTime.c
===================================================================
--- /trunk/psLib/src/astronomy/psTime.c	(revision 3711)
+++ /trunk/psLib/src/astronomy/psTime.c	(revision 3712)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 00:17:05 $
+ *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 02:13:53 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -64,5 +64,5 @@
 
                 /** Microseconds per day */
-                #define USEC_PER_DAY 86400000000.0
+                #define NSEC_PER_DAY 86400000000000.0
 
                 /** Time metadata read from config file */
@@ -363,6 +363,7 @@
 
     outTime->sec = 0;
-    outTime->usec = 0;
+    outTime->nsec = 0;
     outTime->type = type;
+    outTime->leapsecond = false;
 
     return outTime;
@@ -386,5 +387,5 @@
     // Convert timeval time to psTime
     time->sec = now.tv_sec;
-    time->usec = now.tv_usec;
+    time->nsec = now.tv_usec*1000;
 
     // Add most leapseconds to UTC time to get TAI time if necessary
@@ -403,5 +404,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     if (time->type == type) { // time already right type.  That was easy!
@@ -448,5 +449,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     // Calculate TAI or UTC time based on type of time user passes
@@ -455,10 +456,10 @@
         utcTime = psTimeAlloc(PS_TIME_UTC);
         utcTime->sec = taiTime->sec - psTimeGetTAIDelta(time);
-        utcTime->usec = taiTime->usec;
+        utcTime->nsec = taiTime->nsec;
     } else if(time->type == PS_TIME_UTC) {
         utcTime = psMemIncrRefCounter(time);
         taiTime = psTimeAlloc(PS_TIME_TAI);
         taiTime->sec = utcTime->sec + psTimeGetTAIDelta(time);
-        taiTime->usec = utcTime->usec;
+        taiTime->nsec = utcTime->nsec;
     }
 
@@ -519,5 +520,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     if(time->type != PS_TIME_TAI) {
@@ -592,5 +593,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     if(time->type != PS_TIME_TAI)
@@ -715,5 +716,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     // Check time metadata
@@ -768,6 +769,6 @@
     PS_PTR_CHECK_NULL(time1,0);
     PS_PTR_CHECK_NULL(time2,0);
-    PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0);
-    PS_INT_CHECK_RANGE(time2->usec,0,1e6-1,0);
+    PS_INT_CHECK_RANGE(time1->nsec,0,1e9-1,0);
+    PS_INT_CHECK_RANGE(time2->nsec,0,1e9-1,0);
     diff = abs((psS64)psTimeGetTAIDelta((psTime*)time1)-(psS64)psTimeGetTAIDelta((psTime*)time2));
 
@@ -781,11 +782,11 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     // Julian date conversion
     if(time->sec < 0) {
-        jd = time->sec / SEC_PER_DAY - time->usec / USEC_PER_DAY + 2440587.5; // psTime earlier than epoch
+        jd = time->sec / SEC_PER_DAY - time->nsec / NSEC_PER_DAY + 2440587.5; // psTime earlier than epoch
     } else {
-        jd = time->sec / SEC_PER_DAY + time->usec / USEC_PER_DAY + 2440587.5; // psTime greater than epoch
+        jd = time->sec / SEC_PER_DAY + time->nsec / NSEC_PER_DAY + 2440587.5; // psTime greater than epoch
     }
 
@@ -800,11 +801,11 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NAN);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NAN);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NAN);
 
     // Modified Julian date conversion
     if(time->sec < 0) {
-        mjd = time->sec / SEC_PER_DAY - time->usec / USEC_PER_DAY + 40587.0; // psTime earlier than epoch
+        mjd = time->sec / SEC_PER_DAY - time->nsec / NSEC_PER_DAY + 40587.0; // psTime earlier than epoch
     } else {
-        mjd = time->sec / SEC_PER_DAY + time->usec / USEC_PER_DAY + 40587.0; // psTime greater than epoch
+        mjd = time->sec / SEC_PER_DAY + time->nsec / NSEC_PER_DAY + 40587.0; // psTime greater than epoch
     }
 
@@ -823,10 +824,10 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     tempString = psAlloc(MAX_TIME_STRING_LENGTH);
     timeString = psAlloc(MAX_TIME_STRING_LENGTH);
 
-    ms = time->usec / 1000;
+    ms = time->nsec / 1000000;
     sec = time->sec;
 
@@ -856,8 +857,8 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,timevalTime);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,timevalTime);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,timevalTime);
 
     timevalTime.tv_sec = time->sec;
-    timevalTime.tv_usec = time->usec;
+    timevalTime.tv_usec = time->nsec / 1000;
 
     return timevalTime;
@@ -879,5 +880,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     seconds = time->sec%60;
@@ -941,12 +942,12 @@
     seconds = days * SEC_PER_DAY;
     if(seconds < 0.0) {
-        outTime->usec = (seconds - (psS64)seconds) * -1000000.0;  // psTime earlier than epoch
+        outTime->nsec = (seconds - (psS64)seconds) * -1000000000.0;  // psTime earlier than epoch
     } else {
-        outTime->usec = (seconds - (psS64)seconds) * 1000000.0;   // psTime greater than epoch
+        outTime->nsec = (seconds - (psS64)seconds) * 1000000000.0;   // psTime greater than epoch
     }
     outTime->sec = seconds;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     return outTime;
@@ -967,12 +968,12 @@
     seconds = days * SEC_PER_DAY;
     if(seconds < 0.0) {
-        outTime->usec = (seconds - (psS64)seconds) * -1000000.0;  // psTime earlier than epoch
+        outTime->nsec = (seconds - (psS64)seconds) * -1000000000.0;  // psTime earlier than epoch
     } else {
-        outTime->usec = (seconds - (psS64)seconds) * 1000000.0;   // psTime greater than epoch
+        outTime->nsec = (seconds - (psS64)seconds) * 1000000000.0;   // psTime greater than epoch
     }
     outTime->sec = seconds;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     return outTime;
@@ -1006,5 +1007,5 @@
     // Convert tm time to psTime
     outTime = psTimeFromTM(&tmTime);
-    outTime->usec = millisecond * 1000;
+    outTime->nsec = millisecond * 1000000;
 
     return outTime;
@@ -1024,8 +1025,8 @@
     // Convert to psTime
     outTime->sec = time->tv_sec;
-    outTime->usec = time->tv_usec;
+    outTime->nsec = time->tv_usec * 1000;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     return outTime;
@@ -1083,8 +1084,8 @@
 
     // C's TM does not define a microsecond field. Microseconds must be manipulated by calling function.
-    outTime->usec = 0;
+    outTime->nsec = 0;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     return outTime;
@@ -1100,5 +1101,5 @@
     // Error checks
     PS_PTR_CHECK_NULL(time,NULL);
-    PS_INT_CHECK_RANGE(time->usec,0,1e6-1,NULL);
+    PS_INT_CHECK_RANGE(time->nsec,0,1e9-1,NULL);
 
     // Convert time to TAI if necessary, but without changing input arguments
@@ -1106,5 +1107,5 @@
         tempTime = psTimeAlloc(PS_TIME_UTC);
         tempTime->sec = time->sec;
-        tempTime->usec = time->usec;
+        tempTime->nsec = time->nsec;
         tempTime = psTimeConvert(tempTime, PS_TIME_TAI);
     } else {
@@ -1114,10 +1115,10 @@
     // Create output time
     outTime = psTimeAlloc(PS_TIME_TAI);
-    sec = delta + (psF64)tempTime->sec + (psF64)tempTime->usec/1e6;
+    sec = delta + (psF64)tempTime->sec + (psF64)tempTime->nsec/1e9;
     outTime->sec = sec;
-    outTime->usec = (sec - outTime->sec)*1e6;
+    outTime->nsec = (sec - outTime->sec)*1e9;
 
     // Error check
-    PS_INT_CHECK_RANGE(outTime->usec,0,1e6-1,outTime);
+    PS_INT_CHECK_RANGE(outTime->nsec,0,1e9-1,outTime);
 
     // Convert result to same time type as input
@@ -1142,7 +1143,7 @@
     // Error checks
     PS_PTR_CHECK_NULL(time1,0.0);
-    PS_INT_CHECK_RANGE(time1->usec,0,1e6-1,0.0);
+    PS_INT_CHECK_RANGE(time1->nsec,0,1e9-1,0.0);
     PS_PTR_CHECK_NULL(time2,0.0);
-    PS_INT_CHECK_RANGE(time2->usec,0,1e6-1,0.0);
+    PS_INT_CHECK_RANGE(time2->nsec,0,1e9-1,0.0);
 
     // Convert time to TAI if necessary, but without changing input arguments
@@ -1150,5 +1151,5 @@
         tempTime1 = psTimeAlloc(PS_TIME_UTC);
         tempTime1->sec = time1->sec;
-        tempTime1->usec = time1->usec;
+        tempTime1->nsec = time1->nsec;
         tempTime1 = psTimeConvert(tempTime1, PS_TIME_TAI);
     } else {
@@ -1158,5 +1159,5 @@
         tempTime2 = psTimeAlloc(PS_TIME_UTC);
         tempTime2->sec = time2->sec;
-        tempTime2->usec = time2->usec;
+        tempTime2->nsec = time2->nsec;
         tempTime2 = psTimeConvert(tempTime2, PS_TIME_TAI);
     } else {
@@ -1165,7 +1166,7 @@
 
     uSec1 = tempTime1->sec >= 0 ? 1.0 : -1.0;
-    uSec1 = uSec1*tempTime1->usec/1e6;
+    uSec1 = uSec1*tempTime1->nsec/1e9;
     uSec2 = tempTime2->sec >= 0 ? 1.0 : -1.0;
-    uSec2 = uSec2*tempTime2->usec/1e6;
+    uSec2 = uSec2*tempTime2->nsec/1e9;
     out = (tempTime1->sec-tempTime2->sec) + (uSec1-uSec2);
 
Index: /trunk/psLib/src/astronomy/psTime.h
===================================================================
--- /trunk/psLib/src/astronomy/psTime.h	(revision 3711)
+++ /trunk/psLib/src/astronomy/psTime.h	(revision 3712)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-19 00:17:05 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-19 02:13:53 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -40,4 +40,6 @@
     PS_TIME_TAI,        ///< Temps Atomique International (TAI) time (time with leapseconds).
     PS_TIME_UTC,        ///< Universal Time Coordinated (UTC) time (time without leapseconds).
+    PS_TIME_UT1,        ///< Universal Time corrected for polar motion
+    PS_TIME_TT,         ///< Terrestrial Time
 } psTimeType;
 
@@ -52,5 +54,6 @@
 {
     psS64 sec;          ///< Seconds since epoch, Jan 1, 1970.
-    psU32 usec;         ///< Microseconds since last second.
+    psU32 nsec;         ///< Nanoseconds since last second.
+    psBool leapsecond;  ///< if time falls on UTC leapsecond
     psTimeType type;    ///< Type of time.
 }
Index: /trunk/psLib/test/astronomy/tst_psTime_01.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psTime_01.c	(revision 3711)
+++ /trunk/psLib/test/astronomy/tst_psTime_01.c	(revision 3712)
@@ -23,6 +23,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.24 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-04-19 00:17:06 $
+ *  @version $Revision: 1.25 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-04-19 02:13:53 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -44,5 +44,5 @@
     testTime = (psTime*)psAlloc(sizeof(psTime));
     testTime->sec = 1090434144;
-    testTime->usec = 272044;
+    testTime->nsec = 272044000;
     testTime->type = PS_TIME_TAI;
 
@@ -57,7 +57,7 @@
     // Test B - Print test time
     printPositiveTestHeader(stdout,"psTime", "Print test time");
-    printf("Test time: Seconds = %lld Microseconds = %u\n",
+    printf("Test time: Seconds = %lld Nanoseconds = %u\n",
            (long long int)testTime->sec,
-           testTime->usec);
+           testTime->nsec);
     printFooter(stdout, "psTime", "Print test time", true);
 
@@ -79,7 +79,7 @@
     psTime *timeD = NULL;
     timeD = psTimeFromISO(isoString);
-    printf("psTime: Seconds = %lld Microseconds = %u\n",
+    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
            (long long int)timeD->sec,
-           timeD->usec);
+           timeD->nsec);
     psFree(isoString);
     psFree(timeD);
@@ -92,11 +92,11 @@
     timeE = (psTime*)psAlloc(sizeof(psTime));
     timeE->sec = 1090434144;
-    timeE->usec = 272044;
+    timeE->nsec = 272044000;
     timeE->type = PS_TIME_TAI;
     timeE = psTimeConvert(timeE, PS_TIME_UTC);
     psFree(timeE);
-    printf("psTime: Seconds = %lld Microseconds = %u\n",
+    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
            (long long int)timeE->sec,
-           timeE->usec);
+           timeE->nsec);
     printFooter(stdout, "psTime", "Convert psTime time to UTC time", true);
 
@@ -107,11 +107,11 @@
     timeF = (psTime*)psAlloc(sizeof(psTime));
     timeF->sec = 1090434112;
-    timeF->usec = 272044;
+    timeF->nsec = 272044000;
     timeF->type = PS_TIME_UTC;
     timeF = psTimeConvert(timeF, PS_TIME_TAI);
     psFree(timeF);
-    printf("psTime: Seconds = %lld Microseconds = %u\n",
+    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
            (long long int)timeF->sec,
-           timeF->usec);
+           timeF->nsec);
     printFooter(stdout, "psTime", "Convert UTC time to psTime", true);
 
@@ -129,7 +129,7 @@
     psTime *timeH = NULL;
     timeH = psTimeFromMJD(mjdTime);
-    printf("psTime: Seconds = %lld Microseconds = %u\n",
+    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
            (long long int)timeH->sec,
-           timeH->usec);
+           timeH->nsec);
     psFree(timeH);
     printFooter(stdout, "psTime", "Convert MJD time to psTime", true);
@@ -148,7 +148,7 @@
     psTime *timeJ = NULL;
     timeJ = psTimeFromJD(jdTime);
-    printf("psTime: Seconds = %lld Microseconds = %u\n",
+    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
            (long long int)timeJ->sec,
-           timeJ->usec);
+           timeJ->nsec);
     psFree(timeJ);
     printFooter(stdout, "psTime", "Convert JD time to psTime", true);
@@ -169,7 +169,7 @@
     psTime *timeL = NULL;
     timeL = psTimeFromTimeval(&timevalTime);
-    printf("psTime: Seconds = %lld Microseconds = %u\n",
+    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
            (long long int)timeL->sec,
-           timeL->usec);
+           timeL->nsec);
     psFree(timeL);
     printFooter(stdout, "psTime", "Convert timeval time to psTime", true);
@@ -194,7 +194,7 @@
     psTime *timeN = NULL;
     timeN = psTimeFromTM(tmTime);
-    printf("psTime: Seconds = %lld Microseconds = %u\n",
+    printf("psTime: Seconds = %lld Nanoseconds = %u\n",
            (long long int)timeN->sec,
-           timeN->usec);
+           timeN->nsec);
     psFree(timeN);
     psFree(tmTime);
Index: /trunk/psLib/test/astronomy/tst_psTime_03.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psTime_03.c	(revision 3711)
+++ /trunk/psLib/test/astronomy/tst_psTime_03.c	(revision 3712)
@@ -19,6 +19,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.15 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-04-18 23:30:54 $
+ *  @version $Revision: 1.16 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-04-19 02:13:53 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -30,5 +30,5 @@
 
 #define PRINT_TIME(TEXT,TIME) \
-printf("%s Seconds = %lld Microseconds = %u\n", TEXT, (long long int)TIME->sec, TIME->usec);
+printf("%s Seconds = %lld Nanoseconds = %u\n", TEXT, (long long int)TIME->sec, TIME->nsec);
 
 psS32 main(psS32 argc, char* argv[])
@@ -44,13 +44,13 @@
     time1a = psTimeAlloc(PS_TIME_TAI);
     time1a->sec  = 1;
-    time1a->usec = 111111;
+    time1a->nsec = 111111000;
     timeOut1 = psTimeMath(time1a, time1b);
-    if(timeOut1->sec!=2 && timeOut1->usec!=222222) {
-        printf("ERROR: Incorrect time, %lld:%u. Expected 2:222222\n",(long long int)timeOut1->sec, timeOut1->usec);
+    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 microseconds
+    // Test B - Add two times with overflow in nanoseconds
     printPositiveTestHeader(stdout, "psTime", "Test B - Add two times with overflow in microseconds");
     psTime *time2a = NULL;
@@ -59,8 +59,8 @@
     time2a = psTimeAlloc(PS_TIME_TAI);
     time2a->sec  = 6;
-    time2a->usec = 600001;
+    time2a->nsec = 600001000;
     timeOut2 = psTimeMath(time2a, time2b);
-    if(timeOut2->sec!=12 && timeOut2->usec!=100002) {
-        printf("ERROR: Incorrect time, %lld:%u. Expected 12:100002\n",(long long int)timeOut2->sec, timeOut2->usec);
+    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);
@@ -74,14 +74,14 @@
     time3a = psTimeAlloc(PS_TIME_TAI);
     time3a->sec  = 3;
-    time3a->usec = 333333;
+    time3a->nsec = 333333000;
     timeOut3 = psTimeMath(time3a, time3b);
-    if(timeOut3->sec!=2 && timeOut3->usec!=222222) {
-        printf("ERROR: Incorrect time, %lld:%u. Expected 2:222222\n",(long long int)timeOut3->sec, timeOut3->usec);
+    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 microseconds
-    printPositiveTestHeader(stdout, "psTime", "Test D - Subtact two times with underflow in microseconds");
+    // 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;
@@ -89,10 +89,10 @@
     time4a = psTimeAlloc(PS_TIME_TAI);
     time4a->sec  = 5;
-    time4a->usec = 1;
+    time4a->nsec = 1000;
     timeOut4 = psTimeMath(time4a, time4b);
-    if(timeOut4->sec!=2 && timeOut4->usec!=999997) {
-        printf("ERROR: Incorrect time, %lld:%u. Expected 2:999997\n",(long long int)timeOut4->sec, timeOut4->usec);
-    }
-    printFooter(stdout, "psTime", "Test D - Subtact two times with underflow in microseconds", true);
+    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);
 
 
@@ -105,7 +105,7 @@
     time5b = psTimeAlloc(PS_TIME_TAI);
     time5a->sec  = 8;
-    time5a->usec = 8;
+    time5a->nsec = 8000;
     time5b->sec  = 7;
-    time5b->usec = 7;
+    time5b->nsec = 7000;
     timeOut5 = psTimeDelta(time5a, time5b);
     if(fabs(timeOut5-1.000001) > FLT_EPSILON) {
@@ -123,7 +123,7 @@
     time6b = psTimeAlloc(PS_TIME_TAI);
     time6a->sec  = 8;
-    time6a->usec = 1;
+    time6a->nsec = 1000;
     time6b->sec  = 7;
-    time6b->usec = 7;
+    time6b->nsec = 7000;
     timeOut6 = psTimeDelta(time6a, time6b);
     if(fabs(timeOut6-0.999994) > FLT_EPSILON) {
@@ -140,7 +140,7 @@
     time20b = psTimeAlloc(PS_TIME_UTC);
     time20a->sec = 1090434113;
-    time20a->usec = 272044;
+    time20a->nsec = 272044000;
     time20b->sec = 1090434112;
-    time20b->usec = 272044;
+    time20b->nsec = 272044000;
     timeOut20 = psTimeDelta(time20a, time20b);
     if(fabs(timeOut20-1.000000000) > FLT_EPSILON) {
Index: /trunk/psLib/test/astronomy/verified/tst_psTime_01.stdout
===================================================================
--- /trunk/psLib/test/astronomy/verified/tst_psTime_01.stdout	(revision 3711)
+++ /trunk/psLib/test/astronomy/verified/tst_psTime_01.stdout	(revision 3712)
@@ -14,5 +14,5 @@
 \**********************************************************************************/
 
-Test time: Seconds = 1090434144 Microseconds = 272044
+Test time: Seconds = 1090434144 Nanoseconds = 272044000
 
 ---> TESTPOINT PASSED (psTime{Print test time} | tst_psTime_01.c)
@@ -34,5 +34,5 @@
 \**********************************************************************************/
 
-psTime: Seconds = 1090434144 Microseconds = 272000
+psTime: Seconds = 1090434144 Nanoseconds = 272000000
 
 ---> TESTPOINT PASSED (psTime{Convert ISO time to psTime} | tst_psTime_01.c)
@@ -44,5 +44,5 @@
 \**********************************************************************************/
 
-psTime: Seconds = 1090434112 Microseconds = 272044
+psTime: Seconds = 1090434112 Nanoseconds = 272044000
 
 ---> TESTPOINT PASSED (psTime{Convert psTime time to UTC time} | tst_psTime_01.c)
@@ -54,5 +54,5 @@
 \**********************************************************************************/
 
-psTime: Seconds = 1090434144 Microseconds = 272044
+psTime: Seconds = 1090434144 Nanoseconds = 272044000
 
 ---> TESTPOINT PASSED (psTime{Convert UTC time to psTime} | tst_psTime_01.c)
@@ -74,5 +74,5 @@
 \**********************************************************************************/
 
-psTime: Seconds = 1090434144 Microseconds = 272043
+psTime: Seconds = 1090434144 Nanoseconds = 272043704
 
 ---> TESTPOINT PASSED (psTime{Convert MJD time to psTime} | tst_psTime_01.c)
@@ -94,5 +94,5 @@
 \**********************************************************************************/
 
-psTime: Seconds = 1090434144 Microseconds = 272048
+psTime: Seconds = 1090434144 Nanoseconds = 272048711
 
 ---> TESTPOINT PASSED (psTime{Convert JD time to psTime} | tst_psTime_01.c)
@@ -114,5 +114,5 @@
 \**********************************************************************************/
 
-psTime: Seconds = 1090434144 Microseconds = 272044
+psTime: Seconds = 1090434144 Nanoseconds = 272044000
 
 ---> TESTPOINT PASSED (psTime{Convert timeval time to psTime} | tst_psTime_01.c)
@@ -140,5 +140,5 @@
 \**********************************************************************************/
 
-psTime: Seconds = 1090434144 Microseconds = 0
+psTime: Seconds = 1090434144 Nanoseconds = 0
 
 ---> TESTPOINT PASSED (psTime{Convert tm time to psTime} | tst_psTime_01.c)
Index: /trunk/psLib/test/astronomy/verified/tst_psTime_03.stdout
===================================================================
--- /trunk/psLib/test/astronomy/verified/tst_psTime_03.stdout	(revision 3711)
+++ /trunk/psLib/test/astronomy/verified/tst_psTime_03.stdout	(revision 3712)
@@ -28,10 +28,10 @@
 /***************************** TESTPOINT ******************************************\
 *             TestFile: tst_psTime_03.c                                            *
-*            TestPoint: psTime{Test D - Subtact two times with underflow in microseconds} *
+*            TestPoint: psTime{Test D - Subtact two times with underflow in nanoseconds} *
 *             TestType: Positive                                                   *
 \**********************************************************************************/
 
 
----> TESTPOINT PASSED (psTime{Test D - Subtact two times with underflow in microseconds} | tst_psTime_03.c)
+---> TESTPOINT PASSED (psTime{Test D - Subtact two times with underflow in nanoseconds} | tst_psTime_03.c)
 
 /***************************** TESTPOINT ******************************************\
