CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | List of all members
CppCommon::UtcTime Class Reference

UTC time. More...

#include <time.h>

Inheritance diagram for CppCommon::UtcTime:
CppCommon::Time

Public Member Functions

 UtcTime ()
 Initialize UTC time with a current value. More...
 
 UtcTime (const Timestamp &timestamp)
 Initialize UTC time with a given timestamp. More...
 
template<class Clock , class Duration >
 UtcTime (const std::chrono::time_point< Clock, Duration > &time_point)
 Initialize UTC time with a given std::chrono time point. More...
 
 UtcTime (const Time &time)
 Initialize UTC time with another time value. More...
 
 UtcTime (const LocalTime &time)
 Initialize UTC time with another local time value. More...
 
 Time () noexcept
 Initialize time with an epoch time. More...
 
 Time (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0, int microsecond=0, int nanosecond=0)
 Initialize time with a given date & time components (year, month, day, hour, minute, second, etc.) More...
 
 Time (const Time &) noexcept=default
 
 Time (Time &&) noexcept=default
 
 Time (const Timestamp &timestamp)
 Protected initialize time with a timestamp. More...
 
std::chrono::time_point< std::chrono::system_clock > chrono () const
 Convert date & time to the std::chrono time point. More...
 
- Public Member Functions inherited from CppCommon::Time
 Time () noexcept
 Initialize time with an epoch time. More...
 
 Time (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0, int microsecond=0, int nanosecond=0)
 Initialize time with a given date & time components (year, month, day, hour, minute, second, etc.) More...
 
 Time (const Time &) noexcept=default
 
 Time (Time &&) noexcept=default
 
 ~Time () noexcept=default
 
Timeoperator= (const Timestamp &timestamp)
 
Timeoperator= (const Time &) noexcept=default
 
Timeoperator= (Time &&) noexcept=default
 
Timeoperator+= (const Timespan &offset)
 
Timeoperator-= (const Timespan &offset)
 
std::chrono::time_point< std::chrono::system_clock > chrono () const
 Convert date & time to the std::chrono time point. More...
 
int year () const noexcept
 Get year value (1970-2038 for 32-bit or 1970-3000 for 64-bit) More...
 
int month () const noexcept
 Get month value (1-12) More...
 
Weekday weekday () const noexcept
 Get weekday. More...
 
int day () const noexcept
 Get day value (1-31) More...
 
int hour () const noexcept
 Get hour value (0-23) More...
 
int minute () const noexcept
 Get minute value (0-59) More...
 
int second () const noexcept
 Get second value (0-59) More...
 
int millisecond () const noexcept
 Get millisecond value (0-999) More...
 
int microsecond () const noexcept
 Get microsecond value (0-999) More...
 
int nanosecond () const noexcept
 Get nanosecond value (0-999) More...
 
UtcTimestamp utcstamp () const
 Get UTC timestamp from the current date & time value. More...
 
LocalTimestamp localstamp () const
 Get local timestamp from the current date & time value. More...
 
void swap (Time &time) noexcept
 Swap two instances. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CppCommon::Time
static Time epoch ()
 Get the epoch date & time. More...
 
- Protected Member Functions inherited from CppCommon::Time
 Time (const Timestamp &timestamp)
 Protected initialize time with a timestamp. More...
 
- Protected Attributes inherited from CppCommon::Time
int _year
 Year value. More...
 
int _month
 Month value. More...
 
int _weekday
 Weekday value. More...
 
int _day
 Day value. More...
 
int _hour
 Hour value. More...
 
int _minute
 Minute value. More...
 
int _second
 Second value. More...
 
int _millisecond
 Millisecond value. More...
 
int _microsecond
 Microsecond value. More...
 
int _nanosecond
 Nanosecond value. More...
 

Detailed Description

UTC time.

Examples
time_time.cpp.

Definition at line 208 of file time.h.

Constructor & Destructor Documentation

◆ UtcTime() [1/5]

CppCommon::UtcTime::UtcTime ( )
inline

Initialize UTC time with a current value.

Definition at line 215 of file time.h.

◆ UtcTime() [2/5]

CppCommon::UtcTime::UtcTime ( const Timestamp timestamp)
explicit

Initialize UTC time with a given timestamp.

Parameters
timestamp- Timestamp

Definition at line 140 of file time.cpp.

◆ UtcTime() [3/5]

template<class Clock , class Duration >
CppCommon::UtcTime::UtcTime ( const std::chrono::time_point< Clock, Duration > &  time_point)
inlineexplicit

Initialize UTC time with a given std::chrono time point.

Parameters
time_point- std::chrono time point

Definition at line 226 of file time.h.

◆ UtcTime() [4/5]

CppCommon::UtcTime::UtcTime ( const Time time)
inline

Initialize UTC time with another time value.

Definition at line 228 of file time.h.

◆ UtcTime() [5/5]

CppCommon::UtcTime::UtcTime ( const LocalTime time)
inline

Initialize UTC time with another local time value.

Definition at line 278 of file time.inl.

Member Function Documentation

◆ chrono()

std::chrono::time_point<std::chrono::system_clock> CppCommon::Time::chrono
inline

Convert date & time to the std::chrono time point.

Definition at line 132 of file time.h.

◆ Time() [1/5]

CppCommon::Time::Time
inlinenoexcept

Initialize time with an epoch time.

Definition at line 51 of file time.inl.

◆ Time() [2/5]

CppCommon::Time::Time
defaultnoexcept

◆ Time() [3/5]

CppCommon::Time::Time
explicit

Protected initialize time with a timestamp.

Parameters
timestamp- Timestamp

Definition at line 200 of file time.cpp.

◆ Time() [4/5]

CppCommon::Time::Time
explicit

Initialize time with a given date & time components (year, month, day, hour, minute, second, etc.)

Parameters
year- Year value (1970-2038 for 32-bit or 1970-3000 for 64-bit)
month- Month value (1-12)
day- Day value (1-31)
hour- Hour value (0-23) (default is 0)
minute- Minute value (0-59) (default is 0)
second- Second value (0-59) (default is 0)
millisecond- Millisecond value (0-999) (default is 0)
microsecond- Microsecond value (0-999) (default is 0)
nanosecond- Nanosecond value (0-999) (default is 0)

Definition at line 64 of file time.cpp.

◆ Time() [5/5]

CppCommon::Time::Time
defaultnoexcept

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