Index: trunk/psLib/src/types/psMetadata.c
===================================================================
--- trunk/psLib/src/types/psMetadata.c	(revision 4999)
+++ trunk/psLib/src/types/psMetadata.c	(revision 5000)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-10 00:16:59 $
+ *  @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-12 21:36:54 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -247,4 +247,5 @@
     case PS_META_MULTI:
     case PS_META_ARRAY:
+    case PS_META_TIME:
         // Copy of input data not performed due to variability of data types
         metadataItem->data.V = psMemIncrRefCounter(va_arg(argPtr, psPtr));
@@ -440,4 +441,5 @@
 METADATA_ADD_TYPE(Metadata,psMetadata*,PS_META_META)
 METADATA_ADD_TYPE(Array,psArray*,PS_META_ARRAY)
+METADATA_ADD_TYPE(Time,psTime*,PS_META_TIME)
 
 bool psMetadataRemove(psMetadata *md,
Index: trunk/psLib/src/types/psMetadata.h
===================================================================
--- trunk/psLib/src/types/psMetadata.h	(revision 4999)
+++ trunk/psLib/src/types/psMetadata.h	(revision 5000)
@@ -11,6 +11,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-08-31 02:07:12 $
+*  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-12 21:36:54 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -26,5 +26,5 @@
 #include "psHash.h"
 #include "psList.h"
-#include "psImage.h"
+#include "psTime.h"
 #include "psLookupTable.h"
 
@@ -53,5 +53,6 @@
     PS_META_MULTI,                     ///< Used internally, do not create an metadata item of this type.
     PS_META_META,                      ///< Metadata data (Stored as item.data.md).
-    PS_META_ARRAY                      ///< Array data (Stored as item.data.V).
+    PS_META_ARRAY,                     ///< Array data (Stored as item.data.V).
+    PS_META_TIME                       ///< psTime data (Stored as item.data.V).
 } psMetadataType;
 #define PS_META_IS_PRIMITIVE(TYPE) \
@@ -440,4 +441,17 @@
 );
 
+/** Add a Time to metadata collection.
+ *
+ *  @return psBool:  True for success, False for failure.
+ */
+psBool psMetadataAddTime(
+    psMetadata* md,                    ///< Metadata collection to insert metadata item
+    long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
+    const char* name,                  ///< Name of metadata item
+    int format,                        ///< psMetadataFlag options/flags
+    const char* comment,               ///< Comment for metadata item
+    psTime* value                      ///< Time for metadata item data
+);
+
 /** Add a Hash to metadata collection.
  *
Index: trunk/psLib/src/xml/psXML.c
===================================================================
--- trunk/psLib/src/xml/psXML.c	(revision 4999)
+++ trunk/psLib/src/xml/psXML.c	(revision 5000)
@@ -10,6 +10,6 @@
 *  @author David Robbins, MHPCC
 *
-*  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-08-27 01:33:41 $
+*  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-12 21:36:54 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -54,4 +54,5 @@
     char content[MAXSTR];
     char vec[MAXVEC];
+    char timeVal[MAXSTR];
     int i;
     psMetadataIterator *iter = psMetadataIteratorAlloc(*(psMetadata**)&md, PS_LIST_HEAD, NULL);
@@ -73,4 +74,6 @@
         if ( type == 65547)
             type = PS_DATA_METADATA;
+        if ( type == 65549)
+            type = PS_DATA_TIME;
         switch (type) {
         case PS_DATA_BOOL:
@@ -123,4 +126,30 @@
             new_node = xmlAddSibling(cur_node, new_root);
             psFree(newDoc);
+            break;
+        case PS_DATA_TIME:
+            cur_node = xmlNewChild(root, NULL, (const xmlChar*)"time", (const xmlChar*)"\n");
+            prop = xmlNewProp(cur_node, (const xmlChar*)"name", (const xmlChar*)item->name);
+            if ( ((psTime*)(item->data.V))->type == PS_TIME_UTC )
+                prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"PS_TIME_UTC");
+            else if ( ((psTime*)(item->data.V))->type == PS_TIME_TAI )
+                prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"PS_TIME_TAI");
+            else if ( ((psTime*)(item->data.V))->type == PS_TIME_UT1 )
+                prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"PS_TIME_UT1");
+            else if ( ((psTime*)(item->data.V))->type == PS_TIME_TT )
+                prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"PS_TIME_TT");
+            else {
+                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                        PS_ERRORTEXT_psXML_INVALID_CONTENT);
+                return NULL;
+            }
+            snprintf(content, MAXSTR, "%ld, ", ((psTime*)(item->data.V))->sec);
+            strncpy(timeVal, content, MAXSTR);
+            snprintf(content, MAXSTR, "%u, ", ((psTime*)(item->data.V))->nsec);
+            strncat(timeVal, content, MAXSTR);
+            if ( ((psTime*)(item->data.V))->leapsecond )
+                strncat(timeVal, "T", MAXSTR);
+            else
+                strncat(timeVal, "F", MAXSTR);
+            prop = xmlNewProp(cur_node, (const xmlChar*)"value", (const xmlChar*)timeVal);
             break;
         case PS_DATA_VECTOR:
@@ -140,5 +169,4 @@
                     strncat(vec, content, MAXSTR);
                 }
-
                 break;
             case PS_DATA_F32:
@@ -266,4 +294,38 @@
 }
 
+static void storeTime(psTime *out, char *in)
+{
+    char *endp;
+    long sec = 0;
+    unsigned int nsec = 0;
+
+    sec = strtol(in, &endp, 10);
+    out->sec = sec;
+    if ( !strncmp(endp, ",", 1) )
+        endp++;
+    else
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psXML_INVALID_CONTENT);
+    in = endp;
+    nsec = (unsigned int)strtol(in, &endp, 10);
+    out->nsec = nsec;
+    if ( !strncmp(endp, ",", 1) )
+        endp++;
+    else
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psXML_INVALID_CONTENT);
+    in = endp;
+    if ( !strncmp(in, "false", 10) || !strncmp(in, "f", 10) ||
+            !strncmp(in, "FALSE", 10) || !strncmp(in, " F", 10) )
+        out->leapsecond = false;
+    else if ( !strncmp(in, "true", 10) || !strncmp(in, "t", 10) ||
+              !strncmp(in, "TRUE", 10) || !strncmp(in, "T", 10) )
+        out->leapsecond = true;
+    else {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                PS_ERRORTEXT_psXML_INVALID_CONTENT);
+    }
+}
+
 //Check the xml item for errors.  Returns the data type or PS_DATA_UNKNOWN for errors.//
 static psDataType chkType(xmlNode *node)
@@ -309,4 +371,14 @@
         }
     }
+    if(!strncmp((const char*)node->name, "time", MAXSTR) || !strncmp((const char*)node->name, "TIME", MAXSTR) ) {
+        if (node->properties != NULL && node->properties->name
+                && node->properties->next != NULL && node->properties->next->name != NULL) {
+            return(PS_DATA_TIME);
+        } else {
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                    PS_ERRORTEXT_psXML_INVALID_CONTENT);
+            return(PS_DATA_UNKNOWN);
+        }
+    }
     return(PS_DATA_UNKNOWN);
 }
@@ -385,7 +457,34 @@
                     psFree(vec);
                     break;
+                case PS_DATA_TIME:
+                    strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR);
+                    strncpy(content,
+                            (const char*)cur_node->properties->next->next->children->content, MAXSTR);
+                    psTimeType timeType;
+                    char type[MAXSTR];
+                    strncpy(type, (const char*)cur_node->properties->next->children->content, MAXSTR);
+                    if ( !strncmp(type, "PS_TIME_UTC", MAXSTR) )
+                        timeType = PS_TIME_UTC;
+                    else if ( !strncmp(type, "PS_TIME_TAI", MAXSTR) )
+                        timeType = PS_TIME_TAI;
+                    else if ( !strncmp(type, "PS_TIME_UT1", MAXSTR) )
+                        timeType = PS_TIME_UT1;
+                    else if ( !strncmp(type, "PS_TIME_TT", MAXSTR) )
+                        timeType = PS_TIME_TT;
+                    else {
+                        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                                PS_ERRORTEXT_psXML_INVALID_CONTENT);
+                        psFree(meta);
+                        return NULL;
+                    }
+
+                    psTime *time;
+                    time = psTimeAlloc(timeType);
+                    storeTime(time, content);
+                    psMetadataAddTime(meta, PS_LIST_TAIL, name, 0, "", time);
+                    psFree(time);
+                    break;
                 case PS_DATA_METADATA:
                     strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR);
-                    //                        psMetadata *temp = psMetadataAlloc();
                     psMetadata *temp = NULL;
                     temp = xml2metadata(cur_node->children, nodeNum);
Index: trunk/psLib/src/xml/psXML.h
===================================================================
--- trunk/psLib/src/xml/psXML.h	(revision 4999)
+++ trunk/psLib/src/xml/psXML.h	(revision 5000)
@@ -10,6 +10,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-18 21:44:40 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-12 21:36:54 $
  *
  *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
@@ -31,4 +31,5 @@
 #include "psString.h"
 #include "psConstants.h"
+#include "psTime.h"
 #include "psErrorText.h"
 
Index: trunk/psLib/test/xml/psTime.xml
===================================================================
--- trunk/psLib/test/xml/psTime.xml	(revision 4999)
+++ trunk/psLib/test/xml/psTime.xml	(revision 5000)
@@ -12,4 +12,5 @@
     <item name = "psLib.time.BOOL.value3" psType = "BOOL" value = "t" />
     <item name = "psLib.time.BOOL.value4" psType = "BOOL" value = "F" />
+    <time name = "psLib.TIME.Magazine" psType = "PS_TIME_UTC" value = "1000, 25, F" />
     <vector name = "psLib.time.Vector.S32" psType = "S32" value = "-4, -2, 506"/>
     <vector name = "psLib.time.Vector.F32" psType = "F32" value = "-0.4944, -0.00023, 53262.0"/>
Index: trunk/psLib/test/xml/tst_psXML.c
===================================================================
--- trunk/psLib/test/xml/tst_psXML.c	(revision 4999)
+++ trunk/psLib/test/xml/tst_psXML.c	(revision 5000)
@@ -15,6 +15,6 @@
 *  @author  Dave Robbins, MHPCC
 *
-*  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
-*  @date  $Date: 2005-08-20 01:49:03 $
+*  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
+*  @date  $Date: 2005-09-12 21:36:54 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -121,5 +121,5 @@
         printf("Key Type:  F64      Key Value: %15.3f  ", metadataItem->data.F64);
         break;
-    case PS_DATA_METADATA:
+    case PS_META_META:
         printf("Key Type:  METADATA    ");
         break;
@@ -138,4 +138,21 @@
         printf("%s", (char*)metadataItem->data.V );
         printf("\n");
+    } else if ( !strncmp(metadataItem->name, "psLib.TIME.Magazine", 256) ) {
+        printf("Key Value:   ");
+        printf("%ld, ", ((psTime*)(metadataItem->data.V))->sec );
+        printf("%u, ", ((psTime*)(metadataItem->data.V))->nsec );
+        if( ((psTime*)(metadataItem->data.V))->leapsecond )
+            printf("TRUE  ");
+        else
+            printf("FALSE  ");
+        if( ((psTime*)(metadataItem->data.V))->type == PS_TIME_UTC )
+            printf("PS_TIME_UTC ");
+        else if( ((psTime*)(metadataItem->data.V))->type == PS_TIME_TAI )
+            printf("PS_TIME_TAI ");
+        else if( ((psTime*)(metadataItem->data.V))->type == PS_TIME_UT1 )
+            printf("PS_TIME_UT1 ");
+        else if( ((psTime*)(metadataItem->data.V))->type == PS_TIME_TT )
+            printf("PS_TIME_TT ");
+        printf("\n");
     } else
         printf("Key Comment: %s\n", metadataItem->comment);
Index: trunk/psLib/test/xml/verified/tst_psXML.stdout
===================================================================
--- trunk/psLib/test/xml/verified/tst_psXML.stdout	(revision 4999)
+++ trunk/psLib/test/xml/verified/tst_psXML.stdout	(revision 5000)
@@ -7,8 +7,9 @@
  Key Name:    psLib.time.BOOL.value3  Key Type:  BOOL     Key Value:               1  Key Comment: 
  Key Name:    psLib.time.BOOL.value4  Key Type:  BOOL     Key Value:               0  Key Comment: 
+ Key Name:       psLib.TIME.Magazine  Key type:  psPtr    Key Value:   1000, 25, FALSE  PS_TIME_UTC 
  Key Name:     psLib.time.Vector.S32  Key type:  psPtr    Key Values:   -4  -2  506  
  Key Name:     psLib.time.Vector.F32  Key type:  psPtr    Key Comment: 
  Key Name:     psLib.time.Vector.F64  Key type:  psPtr    Key Comment: 
- Key Name:                      cell  Key type:  psPtr    Key Comment: 
+ Key Name:                      cell  Key Type:  METADATA    Key Comment: 
  Key Name:     psLib.time.tables.dir  Key type:  psPtr    Key Value:   ../../data
 
@@ -16,6 +17,7 @@
  Key Name:    psLib.time.BOOL.value4  Key Type:  BOOL     Key Value:               0  Key Comment: 
  Key Name:      psLib.time.F32.value  Key Type:  F32      Key Value:       50324.422  Key Comment: 
- Key Name:                      cell  Key type:  psPtr    Key Comment: 
+ Key Name:                      cell  Key Type:  METADATA    Key Comment: 
  Key Name:     psLib.time.Vector.F64  Key type:  psPtr    Key Comment: 
+ Key Name:       psLib.TIME.Magazine  Key type:  psPtr    Key Value:   1000, 25, FALSE  PS_TIME_UTC 
  Key Name:      psLib.time.F64.value  Key Type:  F64      Key Value:       80112.490  Key Comment: 
  Key Name:     psLib.time.Vector.S32  Key type:  psPtr    Key Values:   -4  -2  506  
