IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19737


Ignore:
Timestamp:
Sep 24, 2008, 10:04:32 AM (18 years ago)
Author:
Paul Price
Message:
  • GPC1 header keywords for the time don't include the middle 'T', so need to catch this case
  • psTimeStrptime shouldn't generate an error when it can't parse a string because it's being used repeatedly as a test.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psTime.c

    r17023 r19737  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.115 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2008-03-17 23:53:43 $
     12 *  @version $Revision: 1.116 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2008-09-24 20:04:32 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    15321532    psTime *outTime = psTimeStrptime(input, "%Y-%m-%dT%H:%M:%S");
    15331533    if (!outTime) {
     1534        // Try without the middle 'T'
     1535        outTime = psTimeStrptime(input, "%Y-%m-%d %H:%M:%S");
     1536    }
     1537    if (!outTime) {
    15341538        // try for date with assumed 00:00:00 time
    15351539        outTime = psTimeStrptime(input, "%Y-%m-%d");
    1536         if (!outTime) {
    1537             psError(PS_ERR_BAD_PARAMETER_VALUE, true, _("Specified ISO Time string, '%s', is malformed.  Must be in 'YYYY-MM-DDThh:mm:ss.sss' format."), input);
    1538             return NULL;
    1539         }
     1540    }
     1541    if (!outTime) {
     1542        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     1543                _("Specified ISO Time string, '%s', is malformed.  "
     1544                  "Must be in 'YYYY-MM-DDThh:mm:ss.sss' format."), input);
     1545        return NULL;
    15401546    }
    15411547
     
    17421748    char *lastChar = strptime(s, format, &tmTime);
    17431749    if (!lastChar) {
    1744         psError(PS_ERR_UNKNOWN, true, "error parsing time string");
     1750        // No error because this function is called repeatedly as a test.
     1751        // Returning NULL without an error is fine, since we're just saying that it's not readable.
    17451752        return NULL;
    17461753    }
    17471754
     1755    // strptime cannot handle fractional seconds, so we do that ourselves
    17481756    if (*lastChar != '\0') {
    1749         psTrace("psLib.astro", 3, "handling fractional second in time string\n");
    1750         // XXXXXXXXXXXXXXX
    1751         // XXX this is a really stupid error:
    1752         // we are dropping the fractional seconds with this conversion
    1753         // I've put in a proposed fix, but PLEASE test!!!
    17541757        if (*lastChar == '.') {
    1755             char *reallyLast;
    1756             fractionalSeconds = strtod (lastChar, &reallyLast);
     1758            char *reallyLast;           // The real last part of the string
     1759            fractionalSeconds = strtod(lastChar, &reallyLast);
    17571760            if (!reallyLast) {
    1758                 psWarning("time string was not completely consumed\n");
     1761                psWarning("Time string was not completely consumed");
    17591762            }
    17601763        }
Note: See TracChangeset for help on using the changeset viewer.