Enigma  3.2.0
A Simple, Reliable and Efficient Encryption Tool
Enigma::DateTimeUtils Namespace Reference

Namespace contains useful Date Time related utility functions. More...

Functions

static std::string toString (const std::time_t &time, const std::string_view &format="%Y-%m-%d %H:%M:%S")
 Converts an std::time_t to a string date time with a specific format. More...
 
static std::time_t fromString (const std::string &dateTimeStr, const std::string_view &format="%Y-%m-%d %H:%M:%S")
 Converts a string date time with a specific format to an std::time_t. More...
 
static std::string now (const std::string_view &format="%Y-%m-%d %H:%M:%S")
 returns current date and time as a string with a specific format More...
 

Detailed Description

Namespace contains useful Date Time related utility functions.

Function Documentation

◆ fromString()

static std::time_t Enigma::DateTimeUtils::fromString ( const std::string &  dateTimeStr,
const std::string_view &  format = "%Y-%m-%d %H:%M:%S" 
)
static

Converts a string date time with a specific format to an std::time_t.

Parameters
dateTimeStrString date time to convert
formatFormat of the string date to return. Default Y-m-d H:M:S (e.g 2023-10-25 12:55:05) https://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html
Returns
std::time_t

Definition at line 30 of file DateTimeUtils.hpp.

◆ now()

static std::string Enigma::DateTimeUtils::now ( const std::string_view &  format = "%Y-%m-%d %H:%M:%S")
static

returns current date and time as a string with a specific format

Parameters
formatFormat of the date to return. Default Y-m-d H:M:S (e.g 2023-10-25 12:55:05) https://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html
Returns
current date time string

Definition at line 40 of file DateTimeUtils.hpp.

◆ toString()

static std::string Enigma::DateTimeUtils::toString ( const std::time_t &  time,
const std::string_view &  format = "%Y-%m-%d %H:%M:%S" 
)
static

Converts an std::time_t to a string date time with a specific format.

Parameters
timestd::time_t value to convert
formatFormat of the date to return. Default Y-m-d H:M:S (e.g 2023-10-25 12:55:05) https://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html
Returns
time as string date time with the specific format

Definition at line 14 of file DateTimeUtils.hpp.