C + + Poco library Chinese Programming Reference Guide (6) Poco::timestamp

Source: Internet
Author: User
Tags arithmetic arithmetic operators bool current time

1 type Alias

Three timestamp-related type aliases, Timediff represents the difference between two timestamps, the second is a timestamp in microseconds, and the third is a timestamp in 100 nanoseconds (0.1 subtle):

typedef Int64 TIMEDIFF; Difference between two timestamps in microseconds

typedef Int64 Timeval; Monotonic UTC time value in microsecond resolution

typedef Int64 Utctimeval; Monotonic UTC time value in nanosecond resolution

2 constructors

Time stamp for current time:

Timestamp ();

Time stamp for the specified time:

Timestamp (Timeval TV);

Copy constructor:

Timestamp (const timestamp& Other);

3 Overloaded Operators

Assignment operator:

timestamp& operator = (const timestamp& other);

timestamp& operator = (timeval TV);

Comparison operators:

BOOL operator = = (CONST timestamp& TS) const;

BOOL operator!= (const timestamp& TS) const;

BOOL operator > (const timestamp& TS) const;

BOOL operator >= (const timestamp& TS) const;

BOOL operator < (const timestamp& TS) const;

BOOL operator <= (const timestamp& TS) const;

Arithmetic operators and arithmetic assignment operators

Timestamp operator + (Timediff d) const;

Timestamp operator-(Timediff d) const;

Timediff operator-(const timestamp& TS) const;

timestamp& operator + = (Timediff d);

timestamp& operator-= (Timediff D);

4 getting the timestamp of different format representations

Gets the timestamp of the std::time_t format:

std::time_t epochtime () const;

Gets the timestamp of the utc-based time format:

Utctimeval utctime () const;

Gets the timestamp of the Timeval format (microseconds):

Timeval epochmicroseconds () const;

5 other member functions

Swap time stamp:

void swap (timestamp& Timestamp);

Update Timestamp is current time:

void Update ();

The difference between the time stamp and the time stamp (TimeStamp ()-*this):

TIMEDIFF elapsed () const;

To determine whether a period of time has passed:

BOOL Iselapsed (Timediff interval) const;

6 Static member functions

Create a timestamp with the std::time_t object:

Static Timestamp Fromepochtime (std::time_t t);

Create a Timestamp with the Utctimeval object:

Static Timestamp Fromutctime (Utctimeval val);

Returns the time resolution, that is, Units per second. Because the minimum resolution of the poco::timestamp is subtle, the function returns 1000000:

Static timeval resolution ();

Reprinted please the famous CSDN blog from Liuda: blog.csdn.net/poechant

View a full set of articles: Http://www.bianceng.cn/Programming/cplus/201301/35022.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.