-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStrftime.cpp
39 lines (29 loc) · 916 Bytes
/
Strftime.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* \file Strftime.cpp
* \brief Format date and time
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//--------------------------------------------------------------------------------------------------
void
logEntry()
{
const std::size_t dateSize {80};
char date[dateSize + 1] {};
// get current date and time
const std::time_t curTime = std::time(nullptr);
const std::tm *localTime = std::localtime(&curTime);
std::strftime(date, dateSize, "%Y-%m-%d %H:%M:%S", localTime);
std::cout << STD_TRACE_VAR(date) << std::endl;
}
//--------------------------------------------------------------------------------------------------
int main(int, char **)
{
::logEntry();
return EXIT_SUCCESS;
}
//--------------------------------------------------------------------------------------------------
#if OUTPUT
date: 2022-06-09 02:01:07
#endif