PMTIMEVALNOW(3)

πŸ“¦
version 6.3.8 Β· 3 versions
, in centos-stream 9, debian trixie, ubuntu questing

πŸ’– PMTIMEVALNOW(3) β€” bestie's guide to the timeval helpers πŸ’–

okay so this is a page from the Library Functions Manual β€” it's all about the lil helper routines for time stored as a struct timeval. no cap, these are the glow-up squad for when you've got time in timeval form and you need to do math on it. πŸ•°οΈβœ¨


✨ NAME ✨

pmtimevalNow, pmtimevalInc, pmtimevalDec, pmtimevalAdd, pmtimevalSub, pmtimevalToReal, pmtimevalFromReal, pmPrintStamp β€” helper routines for time stored as a struct timeval 🫢


πŸŽ€ C SYNOPSIS πŸŽ€

#include <pcp/pmapi.h>

void pmtimevalNow(struct timeval *tv);
void pmtimevalInc(struct timeval *ap, const struct timeval *bp);
void pmtimevalDec(struct timeval *ap, const struct timeval *bp);
double pmtimevalAdd(const struct timeval *ap, const struct timeval *bp);
double pmtimevalSub(const struct timeval *ap, const struct timeval *bp);
double pmtimevalToReal(const struct timeval *val);
void pmtimevalFromReal(double secs, struct timeval *val);
void pmPrintStamp(FILE *f, const struct timeval *tp);

cc ... -lpcp

like literally just link -lpcp and you're in business πŸ’…


🌸 DESCRIPTION 🌸

pmtimevalNow is the platform-independent girlie that grabs the current system time since the Epoch and drops it right into tv. no platform drama, she just delivers. ⭐

pmtimevalInc takes the time in ap, adds the time in bp to it, and stores the result back in ap. and then pmtimevalDec is her mirror twin β€” she subtracts the time in bp from the time in ap and stores the result in ap. in-place queens, they don't make copies, they just edit ap on the spot. πŸ‘‘

pmtimevalAdd (and its sibling pmtimevalSub) add (and subtract) times and hand you back the result as a double value. and the vibe check here? the time in the ap argument is not changed. she's respectful like that, leaves your ap exactly how she found it. πŸ¦‹

pmtimevalToReal converts the time in tp into an equivalent double value. pmtimevalFromReal is the reverse conversion β€” takes the time in secs and returns the equivalent time in val. it's giving round-trip energy, iykyk. πŸ”₯

pmPrintStamp prints the timestamp from tp onto the stream f in local time (as returned by pmLocaltime(3)) in the format HH:MM:SS.XXX. cute lil stamp, very demure, very mindful. πŸŽ€


πŸ’œ NOTES πŸ’œ

if you want variants of these interfaces that use nanosecond precision and the timespec structure instead, go peek at pmtimespecNow(3). same energy, finer detail. ✨


🌈 SEE ALSO 🌈


and that's the whole page bestie!! this one's brought to you by Performance Co-Pilot (aka PCP), and it lives under the PMTIMEVALNOW(3) name in the manual. go forth and do your time math, you absolute icon πŸ’–πŸ’…πŸŒΈπŸ¦‹βœ¨

πŸ“¦ where this page comes from