PMTIMESPECNOW(3)
β¨ PMTIMESPECNOW(3) β¨
okay bestie so this one is from PCP (Performance Co-Pilot) and it lives in the Library Functions Manual section 3, and it's literally just a lil friend group of helpers for handling time when it's stored as a struct timespec π°οΈπ
πΈ NAME πΈ
pmtimespecNow, pmtimespecInc, pmtimespecDec, pmtimespecAdd, pmtimespecSub, pmtimespecToReal, pmtimespecFromReal, pmPrintHighResStamp β helper routines for time stored as a struct timespec β¨
π C SYNOPSIS π
like, include the header first obviously:
#include <pcp/pmapi.h>
and here's the whole squad, character for character π
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 pmPrintHighResStamp(FILE *f, const struct timespec *tp);
and you gotta link it up:
cc ... -lpcp
π¦ DESCRIPTION π¦
β pmtimespecNow
pmtimespecNow is the platform-independent method that returns the current system time since the Epoch in tp. no cap, it just goes and gets you the now πβ¨
β pmtimespecInc and pmtimespecDec
pmtimespecInc adds the time in ap to the time in bp and stores the result in ap. and pmtimespecDec is the reverse vibe β it subtracts the time in bp from the time in ap and stores the result in ap. notice how the answer always lands back in ap? that's the main character of these two π
β pmtimespecAdd and pmtimespecSub
pmtimespecAdd (and pmtimespecSub) add (and subtract) times and return the result as a double value. the time in the ap argument is not changed β she stays exactly as she was, unbothered, moisturized, in her lane π§ββοΈβ¨
β pmtimespecToReal and pmtimespecFromReal
pmtimespecToReal converts the time in tp to an equivalent double value. and pmtimespecFromReal gives you the reverse conversion β it takes the time in secs and returns the equivalent time in tp. it's giving two-way street, it's giving reciprocity π«Ά
β pmPrintHighResStamp
pmPrintHighResStamp 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. that's a whole lotta decimal places and honestly? she earned them π₯
π NOTES π
for variants of these interfaces using microsecond precision and the timeval structure, go check out pmtimevalNow(3). different struct, same energy π¦
π SEE ALSO π
Performance Co-Pilot Β· PCP Β· PMTIMESPECNOW(3) β mwah, that's the whole page bestie, go forth and timestamp responsibly ππβ¨
π¦ where this page comes from
- centos-stream 9: pcp-doc 6.3.7-14.el9 Β· GPL-2.0-or-later AND CC-BY-3.0
- debian trixie: libpcp3-dev 6.3.8-1
- ubuntu questing: libpcp3-dev 6.3.8-1
- Copyright (c) 2022 Red Hat. All Rights Reserved
- Copyright (c) 2017 Ken McDonell. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms