Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::DateTime Class Reference

Date time class. More...

#include <DateTime.h>

Public Types

enum class  Policy { ONLY_CREATE , FORMAT }
 Date creation strategy. More...
 
using Ptr = std::unique_ptr<DateTime>
 

Public Member Functions

 DateTime () noexcept=default
 
 DateTime (uint64_t timestamp, int32_t utc=TIME_DEFAULT_ZONE, Policy policy=Policy::FORMAT) noexcept
 
bool isLeapYear () const noexcept
 
int32_t getYears () const noexcept
 
int32_t getMonths () const noexcept
 
int32_t getDays () const noexcept
 
int32_t getHours () const noexcept
 
int32_t getMinutes () const noexcept
 
int32_t getSeconds () const noexcept
 
int32_t getMilliseconds () const noexcept
 
int32_t getMicroseconds () const noexcept
 
int32_t getUTC () const noexcept
 
int32_t getDayOfWeek () const noexcept
 
int32_t getDayOfYear () const noexcept
 
uint64_t getTimestamp () const noexcept
 
TimeSpan operator- (const DateTime &date_time) const noexcept
 
DateTime operator- (const TimeSpan &time_span) const noexcept
 
DateTime operator+ (const TimeSpan &time_span) const noexcept
 
int32_t compareTo (const DateTime &date_time) const noexcept
 Fine comparisons.
 
int32_t unclearCompareTo (const DateTime &date_time) const noexcept
 Rough comparisons.
 

Static Public Member Functions

static DateTime now (int32_t utc=TIME_DEFAULT_ZONE, Policy policy=Policy::FORMAT) noexcept
 
static DateTime::Ptr nowPtr (int32_t utc=TIME_DEFAULT_ZONE, Policy policy=Policy::FORMAT) noexcept
 

Private Attributes

int32_t years = 1970
 
int32_t months = 1
 
int32_t days = 1
 
int32_t hours = 0
 
int32_t minutes = 0
 
int32_t seconds = 0
 
int32_t dayofweek = 0
 
int32_t dayofyear = 0
 
bool isLeap = false
 
int32_t milliseconds = 0
 
int32_t microseconds = 0
 
int32_t utc = 0
 
uint64_t timestamp = 0
 

Detailed Description

Date time class.

Member Typedef Documentation

◆ Ptr

using sese::DateTime::Ptr = std::unique_ptr<DateTime>

Member Enumeration Documentation

◆ Policy

enum class sese::DateTime::Policy
strong

Date creation strategy.

Enumerator
ONLY_CREATE 

Timestamps are created without parsing to a human-readable time format.

FORMAT 

Create timestamps and parse them into a readable format.

Constructor & Destructor Documentation

◆ DateTime() [1/2]

sese::DateTime::DateTime ( )
explicitdefaultnoexcept

◆ DateTime() [2/2]

sese::DateTime::DateTime ( uint64_t timestamp,
int32_t utc = TIME_DEFAULT_ZONE,
Policy policy = Policy::FORMAT )
explicitnoexcept

Member Function Documentation

◆ compareTo()

int32_t sese::DateTime::compareTo ( const DateTime & date_time) const
nodiscardnoexcept

Fine comparisons.

◆ getDayOfWeek()

int32_t sese::DateTime::getDayOfWeek ( ) const
inlinenodiscardnoexcept

◆ getDayOfYear()

int32_t sese::DateTime::getDayOfYear ( ) const
inlinenodiscardnoexcept

References dayofyear.

◆ getDays()

int32_t sese::DateTime::getDays ( ) const
inlinenodiscardnoexcept

References days.

Referenced by sese::text::DateTimeFormatter::format().

◆ getHours()

int32_t sese::DateTime::getHours ( ) const
inlinenodiscardnoexcept

References hours.

Referenced by sese::text::DateTimeFormatter::format().

◆ getMicroseconds()

int32_t sese::DateTime::getMicroseconds ( ) const
inlinenodiscardnoexcept

◆ getMilliseconds()

int32_t sese::DateTime::getMilliseconds ( ) const
inlinenodiscardnoexcept

◆ getMinutes()

int32_t sese::DateTime::getMinutes ( ) const
inlinenodiscardnoexcept

◆ getMonths()

int32_t sese::DateTime::getMonths ( ) const
inlinenodiscardnoexcept

References months.

Referenced by sese::text::DateTimeFormatter::format().

◆ getSeconds()

int32_t sese::DateTime::getSeconds ( ) const
inlinenodiscardnoexcept

◆ getTimestamp()

uint64_t sese::DateTime::getTimestamp ( ) const
inlinenodiscardnoexcept

References timestamp.

Referenced by operator+(), and operator-().

◆ getUTC()

int32_t sese::DateTime::getUTC ( ) const
inlinenodiscardnoexcept

References utc.

Referenced by sese::text::DateTimeFormatter::format().

◆ getYears()

int32_t sese::DateTime::getYears ( ) const
inlinenodiscardnoexcept

References years.

Referenced by sese::text::DateTimeFormatter::format().

◆ isLeapYear()

bool sese::DateTime::isLeapYear ( ) const
inlinenodiscardnoexcept

References isLeap.

◆ now()

DateTime sese::DateTime::now ( int32_t utc = TIME_DEFAULT_ZONE,
Policy policy = Policy::FORMAT )
staticnoexcept

◆ nowPtr()

DateTime::Ptr sese::DateTime::nowPtr ( int32_t utc = TIME_DEFAULT_ZONE,
Policy policy = Policy::FORMAT )
staticnoexcept

◆ operator+()

DateTime sese::DateTime::operator+ ( const TimeSpan & time_span) const
noexcept

References getTimestamp().

◆ operator-() [1/2]

TimeSpan sese::DateTime::operator- ( const DateTime & date_time) const
noexcept

◆ operator-() [2/2]

DateTime sese::DateTime::operator- ( const TimeSpan & time_span) const
noexcept

References getTimestamp().

◆ unclearCompareTo()

int32_t sese::DateTime::unclearCompareTo ( const DateTime & date_time) const
nodiscardnoexcept

Rough comparisons.

Member Data Documentation

◆ dayofweek

int32_t sese::DateTime::dayofweek = 0
private

Referenced by getDayOfWeek().

◆ dayofyear

int32_t sese::DateTime::dayofyear = 0
private

Referenced by getDayOfYear().

◆ days

int32_t sese::DateTime::days = 1
private

Referenced by getDays().

◆ hours

int32_t sese::DateTime::hours = 0
private

Referenced by getHours().

◆ isLeap

bool sese::DateTime::isLeap = false
private

Referenced by isLeapYear().

◆ microseconds

int32_t sese::DateTime::microseconds = 0
private

Referenced by getMicroseconds().

◆ milliseconds

int32_t sese::DateTime::milliseconds = 0
private

Referenced by getMilliseconds().

◆ minutes

int32_t sese::DateTime::minutes = 0
private

Referenced by getMinutes().

◆ months

int32_t sese::DateTime::months = 1
private

Referenced by getMonths().

◆ seconds

int32_t sese::DateTime::seconds = 0
private

Referenced by getSeconds().

◆ timestamp

uint64_t sese::DateTime::timestamp = 0
private

Referenced by getTimestamp().

◆ utc

int32_t sese::DateTime::utc = 0
private

Referenced by getUTC().

◆ years

int32_t sese::DateTime::years = 1970
private

Referenced by getYears().


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