plugify 1.2.6
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
plugify::DateTime Class Reference

Public Member Functions

template<typename Rep , typename Period >
constexpr DateTime (const std::chrono::duration< Rep, Period > &duration) noexcept
 Constructs a DateTime object from a duration.
 
template<typename T = float>
constexpr auto AsSeconds () const noexcept
 Converts the time duration to seconds.
 
template<typename T = double>
constexpr auto AsMilliseconds () const noexcept
 Converts the time duration to milliseconds.
 
template<typename T = uint64_t>
constexpr auto AsMicroseconds () const noexcept
 Converts the time duration to microseconds.
 
template<typename Rep , typename Period >
constexpr operator std::chrono::duration< Rep, Period > () const noexcept
 Converts the DateTime object to a standard chrono duration.
 
constexpr bool operator== (const DateTime &rhs) const noexcept
 Compares if two DateTime objects are equal.
 
constexpr bool operator!= (const DateTime &rhs) const noexcept
 Compares if two DateTime objects are not equal.
 
constexpr bool operator< (const DateTime &rhs) const noexcept
 Compares if one DateTime object is less than another.
 
constexpr bool operator<= (const DateTime &rhs) const noexcept
 Compares if one DateTime object is less than or equal to another.
 
constexpr bool operator> (const DateTime &rhs) const noexcept
 Compares if one DateTime object is greater than another.
 
constexpr bool operator>= (const DateTime &rhs) const noexcept
 Compares if one DateTime object is greater than or equal to another.
 
constexpr DateTime operator- () const noexcept
 Negates the DateTime value.
 
constexpr DateTimeoperator+= (const DateTime &rhs) noexcept
 Adds another DateTime object to this one.
 
constexpr DateTimeoperator-= (const DateTime &rhs) noexcept
 Subtracts another DateTime object from this one.
 
constexpr DateTimeoperator*= (float rhs) noexcept
 Multiplies this DateTime object by a floating-point value.
 
constexpr DateTimeoperator*= (int64_t rhs) noexcept
 Multiplies this DateTime object by an integer value.
 
constexpr DateTimeoperator/= (float rhs) noexcept
 Divides this DateTime object by a floating-point value.
 
constexpr DateTimeoperator/= (int64_t rhs) noexcept
 Divides this DateTime object by an integer value.
 

Static Public Member Functions

template<typename T = float>
static constexpr DateTime Seconds (const T &seconds) noexcept
 Creates a DateTime object representing seconds.
 
template<typename T = double>
static constexpr DateTime Milliseconds (const T &milliseconds) noexcept
 Creates a DateTime object representing milliseconds.
 
template<typename T = uint64_t>
static constexpr DateTime Microseconds (const T &microseconds) noexcept
 Creates a DateTime object representing microseconds.
 
static DateTime Now () noexcept
 Gets the current time since a local epoch.
 
static std::string Get (std::string_view format="%Y-%m-%d %H:%M:%S")
 Gets the current system time formatted as a string.
 

Friends

constexpr friend DateTime operator+ (const DateTime &lhs, const DateTime &rhs) noexcept
 Adds two DateTime objects.
 
constexpr friend DateTime operator- (const DateTime &lhs, const DateTime &rhs) noexcept
 Subtracts one DateTime object from another.
 
constexpr friend DateTime operator* (const DateTime &lhs, float rhs) noexcept
 Multiplies a DateTime object by a floating-point value.
 
constexpr friend DateTime operator* (const DateTime &lhs, int64_t rhs) noexcept
 Multiplies a DateTime object by an integer value.
 
constexpr friend DateTime operator* (float lhs, const DateTime &rhs) noexcept
 Multiplies a floating-point value by a DateTime object.
 
constexpr friend DateTime operator* (int64_t lhs, const DateTime &rhs) noexcept
 Multiplies an integer value by a DateTime object.
 
constexpr friend DateTime operator/ (const DateTime &lhs, float rhs) noexcept
 Divides a DateTime object by a floating-point value.
 
constexpr friend DateTime operator/ (const DateTime &lhs, int64_t rhs) noexcept
 Divides a DateTime object by an integer value.
 
constexpr friend double operator/ (const DateTime &lhs, const DateTime &rhs) noexcept
 Divides one DateTime object by another.
 
template<typename Period = std::ratio<1, 1>>
constexpr friend double operator% (const DateTime &lhs, const DateTime &rhs)
 Computes the modulo (remainder) of one DateTime object divided by another.
 

Detailed Description

Definition at line 10 of file date_time.hpp.

Constructor & Destructor Documentation

◆ DateTime()

template<typename Rep , typename Period >
constexpr plugify::DateTime::DateTime ( const std::chrono::duration< Rep, Period > &  duration)
inlineconstexprnoexcept

Constructs a DateTime object from a duration.

Template Parameters
RepThe representation type of the duration (e.g., int, float).
PeriodThe period type of the duration (e.g., seconds, milliseconds).
Parameters
durationThe duration to initialize the DateTime object.

Definition at line 21 of file date_time.hpp.

Member Function Documentation

◆ AsMicroseconds()

template<typename T = uint64_t>
constexpr auto plugify::DateTime::AsMicroseconds ( ) const
inlineconstexprnoexcept

Converts the time duration to microseconds.

Template Parameters
TThe return type of the value (default is uint64_t).
Returns
The duration as microseconds.

Definition at line 72 of file date_time.hpp.

◆ AsMilliseconds()

template<typename T = double>
constexpr auto plugify::DateTime::AsMilliseconds ( ) const
inlineconstexprnoexcept

Converts the time duration to milliseconds.

Template Parameters
TThe return type of the value (default is double).
Returns
The duration as milliseconds.

Definition at line 64 of file date_time.hpp.

◆ AsSeconds()

template<typename T = float>
constexpr auto plugify::DateTime::AsSeconds ( ) const
inlineconstexprnoexcept

Converts the time duration to seconds.

Template Parameters
TThe return type of the value (default is float).
Returns
The duration as seconds.

Definition at line 56 of file date_time.hpp.

◆ Get()

static std::string plugify::DateTime::Get ( std::string_view  format = "%Y-%m-%d %H:%M:%S")
inlinestatic

Gets the current system time formatted as a string.

Parameters
formatThe desired time format (default is "%Y-%m-%d %H:%M:%S").
Returns
A string representation of the current system time.

Definition at line 87 of file date_time.hpp.

◆ Microseconds()

template<typename T = uint64_t>
static constexpr DateTime plugify::DateTime::Microseconds ( const T &  microseconds)
inlinestaticconstexprnoexcept

Creates a DateTime object representing microseconds.

Template Parameters
TThe type of the microseconds value (default is uint64_t).
Parameters
microsecondsThe number of microseconds.
Returns
A DateTime object representing the given microseconds.

Definition at line 48 of file date_time.hpp.

◆ Milliseconds()

template<typename T = double>
static constexpr DateTime plugify::DateTime::Milliseconds ( const T &  milliseconds)
inlinestaticconstexprnoexcept

Creates a DateTime object representing milliseconds.

Template Parameters
TThe type of the milliseconds value (default is double).
Parameters
millisecondsThe number of milliseconds.
Returns
A DateTime object representing the given milliseconds.

Definition at line 39 of file date_time.hpp.

◆ Now()

static DateTime plugify::DateTime::Now ( )
inlinestaticnoexcept

Gets the current time since a local epoch.

Returns
A DateTime object representing the current time.

Definition at line 78 of file date_time.hpp.

◆ operator std::chrono::duration< Rep, Period >()

template<typename Rep , typename Period >
constexpr plugify::DateTime::operator std::chrono::duration< Rep, Period > ( ) const
inlineexplicitconstexprnoexcept

Converts the DateTime object to a standard chrono duration.

Template Parameters
RepThe representation type for the duration (e.g., int, float).
PeriodThe period type for the duration (e.g., seconds, milliseconds).
Returns
The DateTime object as a chrono duration.

Definition at line 111 of file date_time.hpp.

◆ operator!=()

constexpr bool plugify::DateTime::operator!= ( const DateTime rhs) const
inlineconstexprnoexcept

Compares if two DateTime objects are not equal.

Parameters
rhsThe right-hand side DateTime object.
Returns
True if not equal, false otherwise.

Definition at line 127 of file date_time.hpp.

◆ operator*=() [1/2]

constexpr DateTime & plugify::DateTime::operator*= ( float  rhs)
inlineconstexprnoexcept

Multiplies this DateTime object by a floating-point value.

Parameters
rhsThe multiplier value.
Returns
A reference to the modified DateTime object.

Definition at line 251 of file date_time.hpp.

◆ operator*=() [2/2]

constexpr DateTime & plugify::DateTime::operator*= ( int64_t  rhs)
inlineconstexprnoexcept

Multiplies this DateTime object by an integer value.

Parameters
rhsThe multiplier value.
Returns
A reference to the modified DateTime object.

Definition at line 257 of file date_time.hpp.

◆ operator+=()

constexpr DateTime & plugify::DateTime::operator+= ( const DateTime rhs)
inlineconstexprnoexcept

Adds another DateTime object to this one.

Parameters
rhsThe DateTime object to add.
Returns
A reference to the modified DateTime object.

Definition at line 239 of file date_time.hpp.

◆ operator-()

constexpr DateTime plugify::DateTime::operator- ( ) const
inlineconstexprnoexcept

Negates the DateTime value.

Returns
A negated DateTime object.

Definition at line 156 of file date_time.hpp.

◆ operator-=()

constexpr DateTime & plugify::DateTime::operator-= ( const DateTime rhs)
inlineconstexprnoexcept

Subtracts another DateTime object from this one.

Parameters
rhsThe DateTime object to subtract.
Returns
A reference to the modified DateTime object.

Definition at line 245 of file date_time.hpp.

◆ operator/=() [1/2]

constexpr DateTime & plugify::DateTime::operator/= ( float  rhs)
inlineconstexprnoexcept

Divides this DateTime object by a floating-point value.

Parameters
rhsThe divisor value.
Returns
A reference to the modified DateTime object.

Definition at line 263 of file date_time.hpp.

◆ operator/=() [2/2]

constexpr DateTime & plugify::DateTime::operator/= ( int64_t  rhs)
inlineconstexprnoexcept

Divides this DateTime object by an integer value.

Parameters
rhsThe divisor value.
Returns
A reference to the modified DateTime object.

Definition at line 269 of file date_time.hpp.

◆ operator<()

constexpr bool plugify::DateTime::operator< ( const DateTime rhs) const
inlineconstexprnoexcept

Compares if one DateTime object is less than another.

Parameters
rhsThe right-hand side DateTime object.
Returns
True if less than, false otherwise.

Definition at line 133 of file date_time.hpp.

◆ operator<=()

constexpr bool plugify::DateTime::operator<= ( const DateTime rhs) const
inlineconstexprnoexcept

Compares if one DateTime object is less than or equal to another.

Parameters
rhsThe right-hand side DateTime object.
Returns
True if less than or equal, false otherwise.

Definition at line 139 of file date_time.hpp.

◆ operator==()

constexpr bool plugify::DateTime::operator== ( const DateTime rhs) const
inlineconstexprnoexcept

Compares if two DateTime objects are equal.

Parameters
rhsThe right-hand side DateTime object.
Returns
True if equal, false otherwise.

Definition at line 121 of file date_time.hpp.

◆ operator>()

constexpr bool plugify::DateTime::operator> ( const DateTime rhs) const
inlineconstexprnoexcept

Compares if one DateTime object is greater than another.

Parameters
rhsThe right-hand side DateTime object.
Returns
True if greater than, false otherwise.

Definition at line 145 of file date_time.hpp.

◆ operator>=()

constexpr bool plugify::DateTime::operator>= ( const DateTime rhs) const
inlineconstexprnoexcept

Compares if one DateTime object is greater than or equal to another.

Parameters
rhsThe right-hand side DateTime object.
Returns
True if greater than or equal, false otherwise.

Definition at line 151 of file date_time.hpp.

◆ Seconds()

template<typename T = float>
static constexpr DateTime plugify::DateTime::Seconds ( const T &  seconds)
inlinestaticconstexprnoexcept

Creates a DateTime object representing seconds.

Template Parameters
TThe type of the seconds value (default is float).
Parameters
secondsThe number of seconds.
Returns
A DateTime object representing the given seconds.

Definition at line 30 of file date_time.hpp.

Friends And Related Symbol Documentation

◆ operator%

template<typename Period = std::ratio<1, 1>>
constexpr friend double operator% ( const DateTime lhs,
const DateTime rhs 
)
friend

Computes the modulo (remainder) of one DateTime object divided by another.

Template Parameters
PeriodThe time unit for the modulo operation (default is seconds).
Parameters
lhsThe left-hand side DateTime object.
rhsThe right-hand side DateTime object.
Returns
The modulo result as a double in the specified Period.

Definition at line 230 of file date_time.hpp.

◆ operator* [1/4]

constexpr friend DateTime operator* ( const DateTime lhs,
float  rhs 
)
friend

Multiplies a DateTime object by a floating-point value.

Parameters
lhsThe DateTime object.
rhsThe multiplier value.
Returns
A DateTime object scaled by rhs.

Definition at line 178 of file date_time.hpp.

◆ operator* [2/4]

constexpr friend DateTime operator* ( const DateTime lhs,
int64_t  rhs 
)
friend

Multiplies a DateTime object by an integer value.

Parameters
lhsThe DateTime object.
rhsThe multiplier value.
Returns
A DateTime object scaled by rhs.

Definition at line 185 of file date_time.hpp.

◆ operator* [3/4]

constexpr friend DateTime operator* ( float  lhs,
const DateTime rhs 
)
friend

Multiplies a floating-point value by a DateTime object.

Parameters
lhsThe multiplier value.
rhsThe DateTime object.
Returns
A DateTime object scaled by lhs.

Definition at line 192 of file date_time.hpp.

◆ operator* [4/4]

constexpr friend DateTime operator* ( int64_t  lhs,
const DateTime rhs 
)
friend

Multiplies an integer value by a DateTime object.

Parameters
lhsThe multiplier value.
rhsThe DateTime object.
Returns
A DateTime object scaled by lhs.

Definition at line 199 of file date_time.hpp.

◆ operator+

constexpr friend DateTime operator+ ( const DateTime lhs,
const DateTime rhs 
)
friend

Adds two DateTime objects.

Parameters
lhsThe left-hand side DateTime object.
rhsThe right-hand side DateTime object.
Returns
A DateTime object representing the sum of lhs and rhs.

Definition at line 164 of file date_time.hpp.

◆ operator-

constexpr friend DateTime operator- ( const DateTime lhs,
const DateTime rhs 
)
friend

Subtracts one DateTime object from another.

Parameters
lhsThe left-hand side DateTime object.
rhsThe right-hand side DateTime object.
Returns
A DateTime object representing the difference between lhs and rhs.

Definition at line 171 of file date_time.hpp.

◆ operator/ [1/3]

constexpr friend double operator/ ( const DateTime lhs,
const DateTime rhs 
)
friend

Divides one DateTime object by another.

Parameters
lhsThe left-hand side DateTime object.
rhsThe right-hand side DateTime object.
Returns
The ratio of lhs to rhs as a double.

Definition at line 220 of file date_time.hpp.

◆ operator/ [2/3]

constexpr friend DateTime operator/ ( const DateTime lhs,
float  rhs 
)
friend

Divides a DateTime object by a floating-point value.

Parameters
lhsThe DateTime object.
rhsThe divisor value.
Returns
A DateTime object scaled by the inverse of rhs.

Definition at line 206 of file date_time.hpp.

◆ operator/ [3/3]

constexpr friend DateTime operator/ ( const DateTime lhs,
int64_t  rhs 
)
friend

Divides a DateTime object by an integer value.

Parameters
lhsThe DateTime object.
rhsThe divisor value.
Returns
A DateTime object scaled by the inverse of rhs.

Definition at line 213 of file date_time.hpp.


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