mirror of
https://github.com/edubart/otclient.git
synced 2025-05-04 19:49:21 +02:00
Add optional format string for stdext::date_time_string() (#1110)
This commit is contained in:
parent
9c1f519f8a
commit
70400bc83e
@ -45,13 +45,13 @@ std::string resolve_path(const std::string& filePath, std::string sourcePath)
|
|||||||
return sourcePath + filePath;
|
return sourcePath + filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string date_time_string()
|
std::string date_time_string(const char* format/* = "%b %d %Y %H:%M:%S"*/)
|
||||||
{
|
{
|
||||||
char date[32];
|
char date[100];
|
||||||
std::time_t tnow;
|
std::time_t tnow;
|
||||||
std::time(&tnow);
|
std::time(&tnow);
|
||||||
std::tm *ts = std::localtime(&tnow);
|
std::tm *ts = std::localtime(&tnow);
|
||||||
std::strftime(date, 32, "%b %d %Y %H:%M:%S", ts);
|
std::strftime(date, 100, format, ts);
|
||||||
return std::string(date);
|
return std::string(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ template<typename T> T from_string(const std::string& str, T def = T()) { return
|
|||||||
/// Resolve a file path by combining sourcePath with filePath
|
/// Resolve a file path by combining sourcePath with filePath
|
||||||
std::string resolve_path(const std::string& filePath, std::string sourcePath);
|
std::string resolve_path(const std::string& filePath, std::string sourcePath);
|
||||||
/// Get current date and time in a std::string
|
/// Get current date and time in a std::string
|
||||||
std::string date_time_string();
|
std::string date_time_string(const char* format = "%b %d %Y %H:%M:%S");
|
||||||
|
|
||||||
std::string dec_to_hex(uint64_t num);
|
std::string dec_to_hex(uint64_t num);
|
||||||
uint64_t hex_to_dec(const std::string& str);
|
uint64_t hex_to_dec(const std::string& str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user