GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::timespec_get(3) C++ Standard Libary std::timespec_get(3)

std::timespec_get - std::timespec_get


Defined in header <ctime>
int timespec_get( std::timespec* ts, int base ); (1) (since C++17)
#define TIME_UTC /* implementation-defined */ (2) (since C++17)


1) Modifies the std::timespec object pointed to by ts to hold the current calendar
time in the time base base.
2) Expands to a value suitable for use as the base argument of std::timespec_get


Other macro constants beginning with TIME_ may be provided by the implementation to
indicate additional time bases


If base is TIME_UTC, then


* ts->tv_sec is set to the number of seconds since an implementation defined
epoch, truncated to a whole value
* ts->tv_nsec member is set to the integral number of nanoseconds, rounded to the
resolution of the system clock


ts - pointer to an object of type std::timespec
base - TIME_UTC or another nonzero integer value indicating the time base


The value of base if successful, zero otherwise.


The POSIX function clock_gettime(CLOCK_REALTIME, ts) may also be used to populate a
std::timespec with the time since the Epoch.

// Run this code


#include <iostream>
#include <ctime>


int main()
{
std::timespec ts;
std::timespec_get(&ts, TIME_UTC);
char buf[100];
std::strftime(buf, sizeof buf, "%D %T", std::gmtime(&ts.tv_sec));
std::cout << "Current time: " << buf << '.' << ts.tv_nsec << " UTC\n";
}


Current time: 06/24/16 20:07:42.949494132 UTC


timespec time in seconds and nanoseconds
(C++17) (struct)
time returns the current time of the system as time since epoch
(function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.