STTNet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Public Attributes | List of all members
stt::time::Duration Struct Reference

A structure representing a time interval, supporting granularity in days, hours, minutes, seconds, and milliseconds. More...

#include <sttnet_English.h>

Public Member Functions

 Duration (long long a, int b, int c, int d, int e)
 Constructor, taking days, hours, minutes, seconds, milliseconds. More...
 
 Duration ()=default
 
bool operator> (const Duration &b)
 Determine if the current time interval is greater than another time interval. More...
 
bool operator< (const Duration &b)
 Determine if the current time interval is less than another time interval. More...
 
bool operator== (const Duration &b)
 Determine if the current time interval is equal to another time interval. More...
 
bool operator>= (const Duration &b)
 Determine if the current time interval is greater than or equal to another time interval. More...
 
bool operator<= (const Duration &b)
 Determine if the current time interval is less than or equal to another time interval. More...
 
time::Duration operator+ (const time::Duration &b)
 Add two time intervals. More...
 
time::Duration operator- (const time::Duration &b)
 Calculate the difference between two time intervals (current object minus parameter b). More...
 
double convertToDay ()
 Convert the current time interval to a floating-point representation in days. More...
 
double convertToHour ()
 Convert the current time interval to a floating-point representation in hours. More...
 
double convertToMin ()
 Convert the current time interval to a floating-point representation in minutes. More...
 
double convertToSec ()
 Convert the current time interval to a floating-point representation in seconds. More...
 
long long convertToMsec ()
 Convert the current time interval to total milliseconds. More...
 
Duration recoverForm (const long long &t)
 Recover the standard days-hours-minutes-seconds-milliseconds format from given milliseconds. More...
 

Public Attributes

long long day
 Days. More...
 
int hour
 Hours. More...
 
int min
 Minutes. More...
 
int sec
 Seconds. More...
 
int msec
 Milliseconds. More...
 

Detailed Description

A structure representing a time interval, supporting granularity in days, hours, minutes, seconds, and milliseconds.

Note
1. Provides basic operations on time intervals, such as addition, subtraction, comparison, and unit conversion.
2. This structure does not represent an absolute time point, but only the difference between two time points.
3. The internal implementation uses multiple fields instead of a unified timestamp to improve readability and controllability.

Constructor & Destructor Documentation

stt::time::Duration::Duration ( long long  a,
int  b,
int  c,
int  d,
int  e 
)
inline

Constructor, taking days, hours, minutes, seconds, milliseconds.

stt::time::Duration::Duration ( )
default

Member Function Documentation

double stt::time::Duration::convertToDay ( )
inline

Convert the current time interval to a floating-point representation in days.

double stt::time::Duration::convertToHour ( )
inline

Convert the current time interval to a floating-point representation in hours.

double stt::time::Duration::convertToMin ( )
inline

Convert the current time interval to a floating-point representation in minutes.

long long stt::time::Duration::convertToMsec ( )
inline

Convert the current time interval to total milliseconds.

double stt::time::Duration::convertToSec ( )
inline

Convert the current time interval to a floating-point representation in seconds.

time::Duration stt::time::Duration::operator+ ( const time::Duration b)
inline

Add two time intervals.

Parameters
bAnother Duration to add.
Returns
The resulting Duration after addition.
time::Duration stt::time::Duration::operator- ( const time::Duration b)
inline

Calculate the difference between two time intervals (current object minus parameter b).

Parameters
bAnother Duration to subtract.
Returns
The resulting Duration of the difference.
bool stt::time::Duration::operator< ( const Duration b)
inline

Determine if the current time interval is less than another time interval.

Parameters
bAnother Duration instance to compare.
Returns
True if the current object is less than parameter b, otherwise false.
bool stt::time::Duration::operator<= ( const Duration b)
inline

Determine if the current time interval is less than or equal to another time interval.

Parameters
bAnother Duration instance to compare.
Returns
True if the current object is less than or equal to parameter b, otherwise false.
bool stt::time::Duration::operator== ( const Duration b)
inline

Determine if the current time interval is equal to another time interval.

Parameters
bAnother Duration instance to compare.
Returns
True if the current object is equal to parameter b, otherwise false.
bool stt::time::Duration::operator> ( const Duration b)
inline

Determine if the current time interval is greater than another time interval.

Parameters
bAnother Duration instance to compare.
Returns
True if the current object is greater than parameter b, otherwise false.
bool stt::time::Duration::operator>= ( const Duration b)
inline

Determine if the current time interval is greater than or equal to another time interval.

Parameters
bAnother Duration instance to compare.
Returns
True if the current object is greater than or equal to parameter b, otherwise false.
Duration stt::time::Duration::recoverForm ( const long long &  t)
inline

Recover the standard days-hours-minutes-seconds-milliseconds format from given milliseconds.

Parameters
tThe millisecond value to recover.
Returns
The converted Duration.

Member Data Documentation

long long stt::time::Duration::day

Days.

int stt::time::Duration::hour

Hours.

int stt::time::Duration::min

Minutes.

int stt::time::Duration::msec

Milliseconds.

int stt::time::Duration::sec

Seconds.


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