AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
anch::date::Date Class Reference

#include <date.hpp>

+ Inheritance diagram for anch::date::Date:
+ Collaboration diagram for anch::date::Date:

Public Member Functions

 Date (bool init=true)
 
 Date (const std::time_t &time)
 
 Date (const std::tm *const time)
 
 Date (const std::timespec &time)
 
virtual ~Date ()
 
bool after (const Date &date) const noexcept
 
bool before (const Date &date) const noexcept
 
bool equals (const Date &date) const noexcept
 
bool operator> (const Date &date) const noexcept
 
bool operator>= (const Date &date) const noexcept
 
bool operator< (const Date &date) const noexcept
 
bool operator<= (const Date &date) const noexcept
 
bool operator== (const Date &date) const noexcept
 
bool operator!= (const Date &date) const noexcept
 
 operator std::time_t () const noexcept
 
 operator std::tm () const noexcept
 
 operator std::timespec () const noexcept
 

Protected Attributes

std::int64_t _timestamp
 
int32_t _years = 0
 
uint16_t _months = 0
 
uint16_t _ydays = 0
 
uint16_t _mdays = 0
 
uint16_t _wdays = 0
 
uint16_t _hours = 0
 
uint16_t _minutes = 0
 
uint16_t _seconds = 0
 
uint16_t _milliseconds = 0
 
uint16_t _microseconds = 0
 
uint16_t _nanoseconds = 0
 

Static Protected Attributes

static std::mutex _mutex
 

Friends

class formatter::IDatePartFormatter
 
class DateFormatter
 

Detailed Description

Date and time utility class.

The class implementation is thread safe (when using this class).
POSIX time management is not thread safe. This class uses POSIX implementation.
Be aware that if you use the POSIX API, you will loose the thread safe support provided in this implementation.

Author
Vincent Lachenal

Constructor & Destructor Documentation

◆ Date() [1/4]

anch::date::Date::Date ( bool init = true)

Date default constructor.

Parameters
initInitialize the Date to now (default true)

◆ Date() [2/4]

anch::date::Date::Date ( const std::time_t & time)

Date constructor.

Parameters
timeThe time to set

◆ Date() [3/4]

anch::date::Date::Date ( const std::tm *const time)

Date constructor.

Parameters
timeThe time to set

◆ Date() [4/4]

anch::date::Date::Date ( const std::timespec & time)

Date constructor.

Parameters
timeThe time to set

◆ ~Date()

virtual anch::date::Date::~Date ( )
virtual

Date destructor

Reimplemented in anch::sql::Date.

Member Function Documentation

◆ after()

bool anch::date::Date::after ( const Date & date) const
inlinenoexcept

Check if current Date is after another one.

Parameters
dateThe other Date
Returns
true if current Date is after the other one, false otherwise.
+ Here is the call graph for this function:

◆ before()

bool anch::date::Date::before ( const Date & date) const
inlinenoexcept

Check if current Date is before another one.

Parameters
dateThe other Date
Returns
true if current Date is before the other one, false otherwise.
+ Here is the call graph for this function:

◆ equals()

bool anch::date::Date::equals ( const Date & date) const
inlinenoexcept

Check if current Date is equals to another one.

Parameters
dateThe other Date
Returns
true if current Date is equals to the other one, false otherwise.
+ Here is the call graph for this function:

◆ operator std::time_t()

anch::date::Date::operator std::time_t ( ) const
inlinenoexcept

Cast operator to std::time_t definition.

Returns
The converted std::time_t

◆ operator std::timespec()

anch::date::Date::operator std::timespec ( ) const
inlinenoexcept

Cast operator to std::timespec definition.

Returns
The converted std::timespec

◆ operator std::tm()

anch::date::Date::operator std::tm ( ) const
inlinenoexcept

Cast operator to std::tm definition.

Returns
The converted std::tm

◆ operator!=()

bool anch::date::Date::operator!= ( const Date & date) const
inlinenoexcept

'!=' operator definition. Calls equals method

Parameters
dateThe date to compare to
+ Here is the call graph for this function:

◆ operator<()

bool anch::date::Date::operator< ( const Date & date) const
inlinenoexcept

'<' operator definition. Calls before method

Parameters
dateThe date to compare to
+ Here is the call graph for this function:

◆ operator<=()

bool anch::date::Date::operator<= ( const Date & date) const
inlinenoexcept

'<=' operator definition. Calls before and equals methods

Parameters
dateThe date to compare to
+ Here is the call graph for this function:

◆ operator==()

bool anch::date::Date::operator== ( const Date & date) const
inlinenoexcept

'==' operator definition. Calls equals method

Parameters
dateThe date to compare to
+ Here is the call graph for this function:

◆ operator>()

bool anch::date::Date::operator> ( const Date & date) const
inlinenoexcept

'>' operator definition. Calls after method

Parameters
dateThe date to compare to
+ Here is the call graph for this function:

◆ operator>=()

bool anch::date::Date::operator>= ( const Date & date) const
inlinenoexcept

'>=' operator definition. Calls after and equals methods

Parameters
dateThe date to compare to
+ Here is the call graph for this function:

Member Data Documentation

◆ _hours

uint16_t anch::date::Date::_hours = 0
protected

The minutes (0-23 => 5 bits)

◆ _mdays

uint16_t anch::date::Date::_mdays = 0
protected

The days of the year (1-31 => 5 bits)

◆ _microseconds

uint16_t anch::date::Date::_microseconds = 0
protected

The microseconds (0-999 => 10 bits)

◆ _milliseconds

uint16_t anch::date::Date::_milliseconds = 0
protected

The milliseconds (0-999 => 10 bits)

◆ _minutes

uint16_t anch::date::Date::_minutes = 0
protected

The minutes (0-59 => 6 bits)

◆ _months

uint16_t anch::date::Date::_months = 0
protected

The months (0-11 => 4 bits)

◆ _mutex

std::mutex anch::date::Date::_mutex
staticprotected

Mutex for thread-safe implementation

◆ _nanoseconds

uint16_t anch::date::Date::_nanoseconds = 0
protected

The nanoseconds (0-999 => 10 bits)

◆ _seconds

uint16_t anch::date::Date::_seconds = 0
protected

The seconds (0-60 => 6 bits)

◆ _timestamp

std::int64_t anch::date::Date::_timestamp
protected

The timestamp

◆ _wdays

uint16_t anch::date::Date::_wdays = 0
protected

The days of the week (0-6 => 3 bits)

◆ _ydays

uint16_t anch::date::Date::_ydays = 0
protected

The days of the year (0-365 => 9 bits)

◆ _years

int32_t anch::date::Date::_years = 0
protected

The years


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