Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
TimeOperations.hpp
Go to the documentation of this file.
1
12#ifndef TIME_OPERATIONS_HPP
13#define TIME_OPERATIONS_HPP
14
16#include <chrono>
17#include <ctime>
18#include <iomanip>
19#include <sstream>
20#include <string>
21
23
24
31namespace timeops
32{
33
42 inline std::string GetTimestamp(const std::string& szFormat = "%Y%m%d-%H%M%S")
43 {
44 // Retrieve the current time
45 auto now = std::chrono::system_clock::now();
46 time_t timeNow = std::chrono::system_clock::to_time_t(now);
47
48 // Convert to local time (thread-safe)
49 tm localTime{};
50 localtime_r(&timeNow, &localTime);
51
52 // Format the time
53 std::ostringstream oss;
54 oss << std::put_time(&localTime, szFormat.c_str());
55 return oss.str();
56 }
57} // namespace timeops
58
59#endif // TIME_OPERATIONS_HPP
Namespace containing functions related to operations on time and date related data types.
Definition TimeOperations.hpp:32
std::string GetTimestamp(const std::string &szFormat="%Y%m%d-%H%M%S")
Accessor for getting the current time in a specified format.
Definition TimeOperations.hpp:42