Index: trunk/psModules/src/concepts/pmConceptsStandard.c
===================================================================
--- trunk/psModules/src/concepts/pmConceptsStandard.c	(revision 7281)
+++ trunk/psModules/src/concepts/pmConceptsStandard.c	(revision 7311)
@@ -69,5 +69,5 @@
                     sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
             {
-                psError(PS_ERR_IO, true, "Cannot interpret FPA.RA: %s\n", concept->data.V);
+                psError(PS_ERR_UNKNOWN, true, "Cannot interpret FPA.RA: %s\n", concept->data.V);
                 break;
             }
@@ -80,5 +80,5 @@
         break;
     default:
-        psError(PS_ERR_IO, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type);
+        psError(PS_ERR_UNKNOWN, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type);
         return NULL;
     }
@@ -171,9 +171,8 @@
     assert(pattern);
 
-    psRegion *trimsec = psAlloc(sizeof(psRegion)); // Make space for a psRegion (usually passed by value)
+    psRegion *trimsec = psRegionAlloc(0, 0, 0, 0);
 
     if (concept->type != PS_DATA_STRING) {
-        psError(PS_ERR_IO, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type);
-        *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0);
+        psError(PS_ERR_UNKNOWN, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type);
     } else {
         *trimsec = psRegionFromString(concept->data.V);
@@ -231,5 +230,5 @@
         }
     default:
-        psError(PS_ERR_IO, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "
+        psError(PS_ERR_UNKNOWN, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "
                 "blank.\n");
     }
@@ -259,5 +258,5 @@
                     (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
                      sscanf(binString, "%*d,%d", &binning) != 1)) {
-                psError(PS_ERR_IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
+                psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
             }
         }
@@ -269,5 +268,5 @@
         TYPE_CASE(binning, concept, S32);
     default:
-        psError(PS_ERR_IO, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
+        psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
                 concept->type);
     }
@@ -290,5 +289,5 @@
     psString sys = concept->data.V;     // The time system string
     if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) {
-        psError(PS_ERR_IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
+        psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
     } else if (strcasecmp(sys, "TAI") == 0) {
         timeSys = PS_TIME_TAI;
@@ -300,5 +299,5 @@
         timeSys = PS_TIME_TT;
     } else {
-        psError(PS_ERR_IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
+        psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
     }
 
@@ -334,10 +333,14 @@
     // Get format
     psMetadata *formats = psMetadataLookupMD(&mdok, cameraFormat, "FORMATS");
-    if (!mdok || !formats)
+    if (!mdok || !formats) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to find FORMATS in camera configuration.\n");
         return NULL;
+    }
 
     psString timeFormat = psMetadataLookupStr(&mdok, formats, "CELL.TIME");
-    if (!mdok || !timeFormat || !strlen(timeFormat))
+    if (!mdok || !timeFormat || !strlen(timeFormat)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to find CELL.TIME in FORMATS.\n");
         return NULL;
+    }
 
     // Parse the time format
@@ -385,5 +388,5 @@
             psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
             if (dateItem->type != PS_DATA_STRING) {
-                psError(PS_ERR_IO, true, "Date is not of type STR.\n");
+                psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
                 return NULL;
             }
@@ -392,5 +395,5 @@
             if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
                     sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
-                psError(PS_ERR_IO, true, "Unable to read date: %s\n", dateString);
+                psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
                 return NULL;
             }
@@ -408,7 +411,13 @@
                 year = temp;
             }
-            if (pre2000Time || year < 2000) {
-                year += 2000;
-            }
+            if (year < 100) {
+                if (pre2000Time) {
+                    year += 1900;
+                } else {
+                    year += 2000;
+                }
+            }
+            sprintf(dateString,"%04d-%02d-%02d", year, month, day);
+
             psString timeString = NULL; // The string with the time
             if (timeItem->type == PS_DATA_STRING) {
@@ -427,5 +436,5 @@
                     TYPE_CASE(seconds, timeItem, F64);
                 default:
-                    psError(PS_ERR_IO, true, "Time is not of an expected type: %x\n", timeItem->type);
+                    psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
                     return NULL;
                 }
@@ -440,4 +449,5 @@
             psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
             time = psTimeFromISO(dateTimeString, timeSys);
+            psFree(dateTimeString);
             break;
         }
@@ -463,5 +473,6 @@
                 time = psTimeFromMJD(timeValue);
             } else {
-                psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue);
+                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n",
+                        timeValue);
                 time = psTimeFromJD(timeValue);
             }
@@ -475,5 +486,6 @@
                 time = psTimeFromMJD(timeValue);
             } else {
-                psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue);
+                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n",
+                        timeValue);
                 time = psTimeFromJD(timeValue);
             }
@@ -481,5 +493,5 @@
         }
     default:
-        psError(PS_ERR_IO, true, "Unable to parse CELL.TIME.\n");
+        psError(PS_ERR_UNKNOWN, true, "Unable to parse CELL.TIME.\n");
         return NULL;
     }
@@ -526,5 +538,5 @@
         TYPE_CASE(offset, concept, S32);
     default:
-        psError(PS_ERR_IO, true, "Concept %s is not of integer type, as expected.\n", pattern->name);
+        psError(PS_ERR_UNKNOWN, true, "Concept %s is not of integer type, as expected.\n", pattern->name);
         return NULL;
     }
@@ -724,13 +736,13 @@
         // XXX: Couldn't be bothered doing these right now
         if (pre2000Time) {
-            psError(PS_ERR_IO, true, "Don't you realise it's the twenty-first century?\n");
+            psError(PS_ERR_UNKNOWN, true, "Don't you realise it's the twenty-first century?\n");
             return NULL;
         }
         if (backwardsTime) {
-            psError(PS_ERR_IO, true, "You want it BACKWARDS?  Not right now, thanks.\n");
+            psError(PS_ERR_UNKNOWN, true, "You want it BACKWARDS?  Not right now, thanks.\n");
             return NULL;
         }
         if (usaTime) {
-            psError(PS_ERR_IO, true, "USA?  No OK --- yet.\n");
+            psError(PS_ERR_UNKNOWN, true, "USA?  No OK.\n");
             return NULL;
         }
@@ -778,5 +790,5 @@
 
     if (concept->type != PS_TYPE_S32) {
-        psError(PS_ERR_IO, true, "Concept %s is not of type S32, as expected.\n", concept->name);
+        psError(PS_ERR_UNKNOWN, true, "Concept %s is not of type S32, as expected.\n", concept->name);
         return NULL;
     }
