E-MailRelay
Public Member Functions | Static Public Member Functions | Friends | List of all members
G::SystemTime Class Reference

Represents a unix-epoch time with microsecond resolution. More...

#include <gdatetime.h>

Public Member Functions

 SystemTime (std::time_t, unsigned long us=0UL) noexcept
 Constructor. More...
 
bool isZero () const
 Returns true if zero(). More...
 
bool sameSecond (const SystemTime &other) const noexcept
 Returns true if this time and the other time are the same, at second resolution. More...
 
BrokenDownTime local () const
 Returns the locale-dependent local broken-down time. More...
 
BrokenDownTime utc () const
 Returns the utc broken-down time. More...
 
unsigned int ms () const
 Returns the millisecond fraction. More...
 
unsigned int us () const
 Returns the microsecond fraction. More...
 
std::time_t s () const noexcept
 Returns the number of seconds since the start of the epoch. More...
 
bool operator< (const SystemTime &) const
 Comparison operator. More...
 
bool operator<= (const SystemTime &) const
 Comparison operator. More...
 
bool operator== (const SystemTime &) const
 Comparison operator. More...
 
bool operator!= (const SystemTime &) const
 Comparison operator. More...
 
bool operator> (const SystemTime &) const
 Comparison operator. More...
 
bool operator>= (const SystemTime &) const
 Comparison operator. More...
 
void operator+= (TimeInterval)
 Adds the given interval. Throws on overflow. More...
 
SystemTime operator+ (TimeInterval) const
 Returns this time with given interval added. More...
 
TimeInterval operator- (const SystemTime &start) const
 Returns the given start time's interval() compared to this end time. More...
 
TimeInterval interval (const SystemTime &end) const
 Returns the interval between this time and the given end time. More...
 
void streamOut (std::ostream &) const
 Streams out the time comprised of the s() value, a decimal point, and then the six-digit us() value. More...
 

Static Public Member Functions

static SystemTime now ()
 Factory function for the current time. More...
 
static SystemTime zero ()
 Factory function for the start of the epoch. More...
 

Friends

class G::DateTimeTest
 

Detailed Description

Represents a unix-epoch time with microsecond resolution.

Definition at line 139 of file gdatetime.h.

Constructor & Destructor Documentation

◆ SystemTime()

G::SystemTime::SystemTime ( std::time_t  t,
unsigned long  us = 0UL 
)
explicitnoexcept

Constructor.

The first parameter should be some large positive number. The second parameter can be more than 10^6.

Definition at line 322 of file gdatetime.cpp.

Member Function Documentation

◆ interval()

G::TimeInterval G::SystemTime::interval ( const SystemTime end) const

Returns the interval between this time and the given end time.

Returns TimeInterval::zero() on underflow or TimeInterval::limit() on overflow of TimeInterval::s_type.

Definition at line 338 of file gdatetime.cpp.

◆ isZero()

bool G::SystemTime::isZero ( ) const

Returns true if zero().

Definition at line 397 of file gdatetime.cpp.

◆ local()

G::BrokenDownTime G::SystemTime::local ( ) const

Returns the locale-dependent local broken-down time.

Definition at line 356 of file gdatetime.cpp.

◆ ms()

unsigned int G::SystemTime::ms ( ) const

Returns the millisecond fraction.

Definition at line 367 of file gdatetime.cpp.

◆ now()

G::SystemTime G::SystemTime::now ( )
static

Factory function for the current time.

Definition at line 328 of file gdatetime.cpp.

◆ operator!=()

bool G::SystemTime::operator!= ( const SystemTime other) const

Comparison operator.

Definition at line 420 of file gdatetime.cpp.

◆ operator+()

G::SystemTime G::SystemTime::operator+ ( TimeInterval  interval) const

Returns this time with given interval added.

Throws on overflow.

Definition at line 440 of file gdatetime.cpp.

◆ operator+=()

void G::SystemTime::operator+= ( TimeInterval  i)

Adds the given interval. Throws on overflow.

Definition at line 448 of file gdatetime.cpp.

◆ operator-()

G::TimeInterval G::SystemTime::operator- ( const SystemTime start) const

Returns the given start time's interval() compared to this end time.

Returns TimeInterval::zero() on underflow or TimeInterval::limit() on overflow of TimeInterval::s_type.

Definition at line 333 of file gdatetime.cpp.

◆ operator<()

bool G::SystemTime::operator< ( const SystemTime other) const

Comparison operator.

Definition at line 403 of file gdatetime.cpp.

◆ operator<=()

bool G::SystemTime::operator<= ( const SystemTime other) const

Comparison operator.

Definition at line 409 of file gdatetime.cpp.

◆ operator==()

bool G::SystemTime::operator== ( const SystemTime other) const

Comparison operator.

Definition at line 415 of file gdatetime.cpp.

◆ operator>()

bool G::SystemTime::operator> ( const SystemTime other) const

Comparison operator.

Definition at line 426 of file gdatetime.cpp.

◆ operator>=()

bool G::SystemTime::operator>= ( const SystemTime other) const

Comparison operator.

Definition at line 433 of file gdatetime.cpp.

◆ s()

std::time_t G::SystemTime::s ( ) const
noexcept

Returns the number of seconds since the start of the epoch.

Definition at line 380 of file gdatetime.cpp.

◆ sameSecond()

bool G::SystemTime::sameSecond ( const SystemTime other) const
noexcept

Returns true if this time and the other time are the same, at second resolution.

Definition at line 351 of file gdatetime.cpp.

◆ streamOut()

void G::SystemTime::streamOut ( std::ostream &  stream) const

Streams out the time comprised of the s() value, a decimal point, and then the six-digit us() value.

Definition at line 455 of file gdatetime.cpp.

◆ us()

unsigned int G::SystemTime::us ( ) const

Returns the microsecond fraction.

Definition at line 374 of file gdatetime.cpp.

◆ utc()

G::BrokenDownTime G::SystemTime::utc ( ) const

Returns the utc broken-down time.

Definition at line 361 of file gdatetime.cpp.

◆ zero()

G::SystemTime G::SystemTime::zero ( )
static

Factory function for the start of the epoch.

Definition at line 388 of file gdatetime.cpp.

Friends And Related Function Documentation

◆ G::DateTimeTest

friend class G::DateTimeTest
friend

Definition at line 216 of file gdatetime.h.


The documentation for this class was generated from the following files: