IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7961


Ignore:
Timestamp:
Jul 24, 2006, 3:16:04 PM (20 years ago)
Author:
jhoblitt
Message:

add psTimeStrftime()

Location:
trunk/psLib/src/astro
Files:
2 edited

Legend:

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

    r7942 r7961  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-07-20 12:59:07 $
     12 *  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-07-25 01:16:04 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    16811681}
    16821682
     1683psString psTimeStrftime(const psTime *time, const char *format)
     1684{
     1685    PS_ASSERT_PTR_NON_NULL(time, NULL);
     1686    PS_ASSERT_PTR_NON_NULL(format, NULL);
     1687
     1688    struct tm *tmTime = psTimeToTM(time);
     1689
     1690    psString s = psAlloc(MAX_TIME_STRING_LENGTH);
     1691    size_t size = strftime(s, MAX_TIME_STRING_LENGTH, format, tmTime);
     1692    psFree(tmTime);
     1693    // it's worth nothing that strftime() can zero without an error having
     1694    // occured don't believe it's worth supporting that edge case.  See
     1695    // strftime(3) for further details.
     1696    if (size == 0) {
     1697        psError(PS_ERR_UNKNOWN, true, "failed to stringify a psTime");
     1698        return NULL;
     1699    }
     1700
     1701    return s;
     1702}
     1703
    16831704psTime* psTimeMath(const psTime *time,
    16841705                   double delta)
  • trunk/psLib/src/astro/psTime.h

    r7703 r7961  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-06-27 04:13:07 $
     13 *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-07-25 01:16:04 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    375375
    376376psTime* psTimeStrptime(
    377     const char *s,                  ///< string to be converted
    378     const char *format              ///< strptime format
     377    const char *s,                      ///< string to be converted
     378    const char *format                  ///< strptime(3) format
     379);
     380
     381/** Convert a psTime into a formated string.
     382 *
     383 *  Converts a psTime, using a strftime(3) format, into a formatted string.
     384 *  See strftime(3) for documentation on this format.
     385 *
     386 *  @return  psString: string.
     387 */
     388
     389psString psTimeStrftime(
     390    const psTime *time,                 ///< Time to be formatted.
     391    const char *format                  ///< strftime(3) format
    379392);
    380393
Note: See TracChangeset for help on using the changeset viewer.