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

Local time. More...

#include <time.h>

Inheritance diagram for CppCommon::LocalTime:
CppCommon::Time

Public Member Functions

 LocalTime ()
 Initialize local time with a current value. More...
 
 LocalTime (const Timestamp &timestamp)
 Initialize local time with a given timestamp. More...
 
template<class Clock , class Duration >
 LocalTime (const std::chrono::time_point< Clock, Duration > &time_point)
 Initialize local time with a given std::chrono time point. More...
 
 LocalTime (const Time &time)
 Initialize local time with another time value. More...
 
 LocalTime (const UtcTime &time)
 Initialize local time with another UTC 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

Local time.

Examples
time_time.cpp.

Definition at line 234 of file time.h.

Constructor & Destructor Documentation

◆ LocalTime() [1/5]

CppCommon::LocalTime::LocalTime ( )
inline

Initialize local time with a current value.

Definition at line 241 of file time.h.

◆ LocalTime() [2/5]

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

Initialize local time with a given timestamp.

Parameters
timestamp- Timestamp

Definition at line 163 of file time.cpp.

◆ LocalTime() [3/5]

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

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

Parameters
time_point- std::chrono time point

Definition at line 252 of file time.h.

◆ LocalTime() [4/5]

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

Initialize local time with another time value.

Definition at line 254 of file time.h.

◆ LocalTime() [5/5]

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

Initialize local time with another UTC time value.

Definition at line 281 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: