tgbotxx  1.1.6.9
Telegram Bot C++ Library
tgbotxx::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...
 
static std::string currentDateTime (const std::string_view &format="%Y-%m-%d %H:%M:%S")
 

Detailed Description

Namespace contains useful Date Time related utility functions.

Function Documentation

◆ currentDateTime()

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

Definition at line 46 of file DateTimeUtils.hpp.

◆ fromString()

static std::time_t tgbotxx::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 tgbotxx::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 tgbotxx::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.