Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

timespec c

#include <stdio.h>
#include <time.h>
#include <stdint.h>
 
int main(void)
{
    struct timespec ts;
    timespec_get(&ts, TIME_UTC);
    char buff[100];
    strftime(buff, sizeof buff, "%D %T", gmtime(&ts.tv_sec));
    printf("Current time: %s.%09ld UTC
", buff, ts.tv_nsec);
    printf("Raw timespec.time_t: %jd
", (intmax_t)ts.tv_sec);
    printf("Raw timespec.tv_nsec: %09ld
", ts.tv_nsec);
}
Source by en.cppreference.com #
 
PREVIOUS NEXT
Tagged: #timespec
ADD COMMENT
Topic
Name
4+4 =