IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 7, 2006, 2:30:03 PM (20 years ago)
Author:
jhoblitt
Message:

fix psTimeStrptime() - a hard coded format was being used instead of the format param
reimplement psTimeFromISO() as a wrapper around psTimeStrptime()

File:
1 edited

Legend:

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

    r8627 r8772  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.94 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-08-26 04:34:27 $
     12 *  @version $Revision: 1.95 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-09-08 00:30:03 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    14901490                      psTimeType type)
    14911491{
    1492     psS32 millisecond;
    1493     struct tm tmTime;
    1494     psTime *outTime = NULL;
    14951492
    14961493    // Check for NULL string
     
    14981495    PS_ASSERT_INT_WITHIN_RANGE(type, PS_TIME_TAI, PS_TIME_TT, NULL);
    14991496
    1500     // Convert YYYY-MM-DDThh:mm:ss.sss in string form to tm time
    1501     if (sscanf(input, "%d-%d-%dT%d:%d:%d.%d", &tmTime.tm_year, &tmTime.tm_mon, &tmTime.tm_mday,
    1502                &tmTime.tm_hour, &tmTime.tm_min, &tmTime.tm_sec,&millisecond) < 7) {
     1497    // Convert YYYY-MM-DDThh:mm:ss.sss[Z] in string form to tm time
     1498    psTime *outTime = psTimeStrptime(input, "%Y-%m-%dT%H:%M:%S");
     1499
     1500    if (!outTime) {
    15031501        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);
    15041502        return NULL;
    1505     }
    1506 
    1507     PS_ASSERT_INT_NONNEGATIVE(tmTime.tm_year, outTime);
    1508     PS_ASSERT_INT_WITHIN_RANGE(tmTime.tm_mon,1,12,outTime);
    1509     PS_ASSERT_INT_WITHIN_RANGE(tmTime.tm_mday,1,31,outTime);
    1510     PS_ASSERT_INT_WITHIN_RANGE(tmTime.tm_hour,0,23,outTime);
    1511     PS_ASSERT_INT_WITHIN_RANGE(tmTime.tm_min,0,59,outTime);
    1512     PS_ASSERT_INT_WITHIN_RANGE(tmTime.tm_sec,0,59,outTime);
    1513     PS_ASSERT_INT_WITHIN_RANGE(millisecond,0,999,outTime);
    1514 
    1515     tmTime.tm_year -= 1900;
    1516     tmTime.tm_mon--;
    1517     tmTime.tm_isdst = -1;
    1518 
    1519     // Convert tm time to psTime
    1520     outTime = psTimeFromTM(&tmTime);
    1521     outTime->nsec = millisecond * 1000000;
    1522     //    outTime->type = type;
    1523     if (type != PS_TIME_TAI) {
    1524         outTime = psTimeConvert(outTime, type);
    15251503    }
    15261504
     
    16621640
    16631641    struct tm tmTime;
    1664     char *lastChar = strptime((char *)s, "%EY-%m-%d%t%T", &tmTime);
     1642    char *lastChar = strptime(s, format, &tmTime);
    16651643    if (!lastChar) {
    16661644        psError(PS_ERR_UNKNOWN, true, "error parsing time string");
Note: See TracChangeset for help on using the changeset viewer.