IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8768


Ignore:
Timestamp:
Sep 7, 2006, 11:47:31 AM (20 years ago)
Author:
jhoblitt
Message:

change parseTime() to parse ISO8601 string as is specified in the SDRS

  • note that the previous version of this function, in addition to being incorrect, had potential segvs and numerous coding style violations
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psMetadataConfig.c

    r8767 r8768  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.77 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-09-07 21:24:47 $
     12*  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-09-07 21:47:31 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    295295                         psS32 *status)
    296296{
    297     psTime *out;
    298     long sec = 0;
    299     unsigned int nsec = 0;
    300     char *end = NULL;
    301     out = psTimeAlloc(tt);
    302 
    303     sec = strtol(inString, &end, 10);
    304     out->sec = sec;
    305     while (!strncmp(end, " ", 1))
    306         end++;
    307     inString = end;
    308     nsec = (unsigned int)strtoul(inString, &end, 10);
    309     out->nsec = nsec;
    310     if (out->sec == 0 && out->nsec == 0)
    311         *status = 1;
    312     while (!strncmp(end, " ", 1))
    313         end++;
    314     inString = end;
    315     if ( !strncmp(inString, "false", 10) || !strncmp(inString, "f", 10) ||
    316             !strncmp(inString, "FALSE", 10) || !strncmp(inString, " F", 10) )
    317         out->leapsecond = false;
    318     else if ( !strncmp(inString, "true", 10) || !strncmp(inString, "t", 10) ||
    319               !strncmp(inString, "TRUE", 10) || !strncmp(inString, "T", 10) )
    320         out->leapsecond = true;
    321     else {
    322         *status = 1;
    323     }
     297    PS_ASSERT_PTR_NON_NULL(status, NULL);
     298    if (!inString) {
     299        *status = 0;
     300        return NULL;
     301    }
     302
     303    psTime *out = psTimeFromISO(inString, tt);
     304
     305    if (!out) {
     306        *status = 0;
     307        return NULL;
     308    }
     309
     310    *status = 1;
     311
    324312    return out;
    325313}
Note: See TracChangeset for help on using the changeset viewer.