Safeheron-SGX-Native-Development-Framework v1.2.0
Loading...
Searching...
No Matches
ssgx::utils_t::DateTime Class Reference

Represents a specific point in time. Supports UTC/GMT time only. More...

#include <ssgx_utils_t_time.h>

Public Member Functions

 DateTime () noexcept
 Default constructor, initializes the time to epoch (1970-01-01 00:00:00).
 
 DateTime (time_t timestamp) noexcept
 Constructs a DateTime object from a UNIX timestamp.
 
 DateTime (int num_year, int num_month, int num_day, int num_hour, int num_min, int num_sec)
 Constructs a DateTime object from year, month, day, hour, minute, and second.
 
DateTimeoperator= (time_t timestamp) noexcept
 
DateTimeoperator+= (TimeSpan span) noexcept
 
DateTimeoperator-= (TimeSpan span) noexcept
 
TimeSpan operator- (DateTime time) const noexcept
 
DateTime operator- (TimeSpan span) const noexcept
 
DateTime operator+ (TimeSpan span) const noexcept
 
bool operator== (DateTime time) const noexcept
 
bool operator!= (DateTime time) const noexcept
 
bool operator< (DateTime time) const noexcept
 
bool operator> (DateTime time) const noexcept
 
bool operator<= (DateTime time) const noexcept
 
bool operator>= (DateTime time) const noexcept
 
time_t GetTimestamp () const noexcept
 
int GetYear () const noexcept
 
int GetMonth () const noexcept
 
int GetDay () const noexcept
 
int GetHour () const noexcept
 
int GetMinute () const noexcept
 
int GetSecond () const noexcept
 
int GetDayOfWeek () const noexcept
 
std::string ToFormatTime () const
 Returns the time as a formatted string in "YYYY-MM-DD HH:MM:SS" format.
 

Static Public Member Functions

static DateTime Now ()
 Returns the current system time as a DateTime object.
 
static DateTime FromFormatTime (const std::string &formattedTime)
 Constructs a DateTime object from a formatted string. Supports the format "YYYY-MM-DD HH:MM:SS".
 

Detailed Description

Represents a specific point in time. Supports UTC/GMT time only.

Constructor & Destructor Documentation

◆ DateTime() [1/3]

ssgx::utils_t::DateTime::DateTime ( )
noexcept

Default constructor, initializes the time to epoch (1970-01-01 00:00:00).

◆ DateTime() [2/3]

ssgx::utils_t::DateTime::DateTime ( time_t timestamp)
explicitnoexcept

Constructs a DateTime object from a UNIX timestamp.

Parameters
timestampThe UNIX timestamp.

◆ DateTime() [3/3]

ssgx::utils_t::DateTime::DateTime ( int num_year,
int num_month,
int num_day,
int num_hour,
int num_min,
int num_sec )

Constructs a DateTime object from year, month, day, hour, minute, and second.

Parameters
num_yearYear.
num_monthMonth.
num_dayDay.
num_hourHour.
num_minMinute.
num_secSecond.

Member Function Documentation

◆ FromFormatTime()

static DateTime ssgx::utils_t::DateTime::FromFormatTime ( const std::string & formattedTime)
static

Constructs a DateTime object from a formatted string. Supports the format "YYYY-MM-DD HH:MM:SS".

Parameters
formattedTimeA string representation of the time.
Returns
A DateTime object representing the given time.

◆ GetDay()

int ssgx::utils_t::DateTime::GetDay ( ) const
nodiscardnoexcept

◆ GetDayOfWeek()

int ssgx::utils_t::DateTime::GetDayOfWeek ( ) const
nodiscardnoexcept

◆ GetHour()

int ssgx::utils_t::DateTime::GetHour ( ) const
nodiscardnoexcept

◆ GetMinute()

int ssgx::utils_t::DateTime::GetMinute ( ) const
nodiscardnoexcept

◆ GetMonth()

int ssgx::utils_t::DateTime::GetMonth ( ) const
nodiscardnoexcept

◆ GetSecond()

int ssgx::utils_t::DateTime::GetSecond ( ) const
nodiscardnoexcept

◆ GetTimestamp()

time_t ssgx::utils_t::DateTime::GetTimestamp ( ) const
nodiscardnoexcept

◆ GetYear()

int ssgx::utils_t::DateTime::GetYear ( ) const
nodiscardnoexcept

◆ Now()

static DateTime ssgx::utils_t::DateTime::Now ( )
static

Returns the current system time as a DateTime object.

Exceptions
runtime_errorThrow the exception if the ssgx_ocall_time call fails or the time verification fails.
Returns
The current time.

◆ operator!=()

bool ssgx::utils_t::DateTime::operator!= ( DateTime time) const
noexcept

◆ operator+()

DateTime ssgx::utils_t::DateTime::operator+ ( TimeSpan span) const
noexcept

◆ operator+=()

DateTime & ssgx::utils_t::DateTime::operator+= ( TimeSpan span)
noexcept

◆ operator-() [1/2]

TimeSpan ssgx::utils_t::DateTime::operator- ( DateTime time) const
noexcept

◆ operator-() [2/2]

DateTime ssgx::utils_t::DateTime::operator- ( TimeSpan span) const
noexcept

◆ operator-=()

DateTime & ssgx::utils_t::DateTime::operator-= ( TimeSpan span)
noexcept

◆ operator<()

bool ssgx::utils_t::DateTime::operator< ( DateTime time) const
noexcept

◆ operator<=()

bool ssgx::utils_t::DateTime::operator<= ( DateTime time) const
noexcept

◆ operator=()

DateTime & ssgx::utils_t::DateTime::operator= ( time_t timestamp)
noexcept

◆ operator==()

bool ssgx::utils_t::DateTime::operator== ( DateTime time) const
noexcept

◆ operator>()

bool ssgx::utils_t::DateTime::operator> ( DateTime time) const
noexcept

◆ operator>=()

bool ssgx::utils_t::DateTime::operator>= ( DateTime time) const
noexcept

◆ ToFormatTime()

std::string ssgx::utils_t::DateTime::ToFormatTime ( ) const
nodiscard

Returns the time as a formatted string in "YYYY-MM-DD HH:MM:SS" format.

Returns
A formatted string representation of the time.
Exceptions
std::invalid_argument("Unexpectedexception: int ret = __secs_to_tm(timestamp_, &t);")

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