# pmtimespec

## NAME



           **pmtimespecNow** , **pmtimespecInc** , **pmtimespecDec** , **pmtimespecAdd** ,
           **pmtimespecSub** , **pmtimespecToReal** , **pmtimespecFromReal** ,
           **pmtimespecTotimeval** , **pmtimespecPrint** , **pmtimespecPrintInterval** -
           helper routines for time stored as a struct timespec
    


## C SYNOPSIS



           **#include <pcp/pmapi.h>**
    
           **void pmtimespecNow(struct timespec ***_tp_**);**
           **void pmtimespecInc(struct timespec ***_ap_**, const struct timespec**
           *****_bp_**);**
           **void pmtimespecDec(struct timespec ***_ap_**, const struct timespec**
           *****_bp_**);**
           **double pmtimespecAdd(const struct timespec ***_ap_**,**
                                **const struct timespec ***_bp_**);**
           **double pmtimespecSub(const struct timespec ***_ap_**,**
                                **const struct timespec ***_bp_**);**
           **double pmtimespecToReal(const struct timespec ***_tp_**);**
           **void pmtimespecFromReal(double** _secs_**, struct timespec ***_tp_**);**
           **void pmtimespecTotimeval(struct timespec ***_tsp,_ **struct timeval**
           *****_tvp_**);**
           **void pmtimespecPrint(FILE ***_f_**, const struct timespec ***_tp_**);**
           **void pmtimespecPrintInterval(FILE ***_f_**, const struct timespec ***_tp_**);**
    
           **cc ... -lpcp**
    


## DESCRIPTION



           **pmtimespecNow** is  a  platform-independent method that returns the
           current system time since the Epoch in _tp_.
    
           **pmtimespecInc** adds the time in _ap_ to the time in _bp_ and stores the
           result in _ap_.  Similarly **pmtimespecDec** subtracts the  time  in  _bp_
           from the time in _ap_ and stores the result in _ap_.
    
           **pmtimespecAdd**(and **pmtimespecSub**) add (and subtract) times and re‐
           turn the result as a double value.  The time in the _ap_ argument is
           not changed.
    
           **pmtimespecToReal** converts  the time in _tp_ to an equivalent double
           value.  **pmtimespecFromReal** provides the reverse conversion, taking
           the time in _secs_ and returning the equivalent time in _tp_.
    
           **pmtimespecTotimeval** converts  the  struct  timespec  _tsp_  into  an
           equivalent  struct  timeval  _tvp_ (modulo nanosecond to microsecond
           truncation).
    
           For **pmtimespecAdd** ,  **pmtimespecSub** ,  **pmtimespecToReal** and  **pmtime‐**
           **specFromReal** there  is  an  issue of numerical precision.  If the
           **double** result or operand has more than 6 decimal digits of  preci‐
           sion  in  the seconds part of the value, then the fractional value
           is converted to microseconds before  arithmetic  computations,  so
           the nanoseconds field is only accurate to 6 decimal digits in this
           case.
    
           **pmtimespecPrint** prints  the  timestamp from _tp_ on the stream _f_ in
           the local time (as  returned  by  pmLocaltime(3))  in  the  format
           HH:MM:SS.XXXXXXXXX.
    
           **pmtimespecPrintInterval** prints the interval from _tp_ on the stream
           _f_ in  a  minimalist  format  [[HH**h**]MM**m**]SS[.XXXXXXXXX]**s** where  the
           hours,  minutes and nanoseconds are only reported if they are non-
           zero, and any trailing zeroes in the nanoseconds are omitted.  For
           example if tp->tv_sec was 75 and tp->tv_nsec was 51000000 then the
           output would be **1h15.51s**.
    


## NOTES



           For variants of these interfaces using microsecond  precision  and
           the timeval structure, refer to pmtimevalNow(3).
    


## COMPATIBILITY



           Prior  to  PCP 7.0 the routine **pmtimespecPrint** was called **pmPrint‐**
           **HighResStamp**.  To support PMAPI transition, the  old  routine  can
           still  be  used  if  applications are recompiled with **-DPMAPI_VER‐**
           **SION=2**.
    
           **pmPrintHighResStamp** is now deprecated and compile-time support for
           this routine name will be removed in a future release.
    


* * *