IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

add psTimeStrftime()

File:
1 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)
Note: See TracChangeset for help on using the changeset viewer.