sculpto
current_time.h
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file time_stamp.h
3 * \brief Current time string creation function implementation.
4 *
5 * \author Sabitov Kirill
6 * \date 23 June 2022
7 *********************************************************************/
8
9#pragma once
10
11namespace scl
12{
13 /*!*
14 * Getting curent time string function.
15 *
16 * \param None.
17 * \return Current time as string in format HH:MM:SS.
18 */
19 inline const std::string CurrentTime()
20 {
21 using sysclock_t = std::chrono::system_clock;
22 std::time_t now = sysclock_t::to_time_t(sysclock_t::now());
23 tm local_time;
24 localtime_s(&local_time, &now);
25
26 char buf[16] = { 0 };
27 std::strftime(buf, sizeof(buf), "%H:%M:%S", &local_time);
28
29 return std::string(buf);
30 }
31}
Definition: base.h:33
const std::string CurrentTime()
Definition: current_time.h:19