Introduction
The Time Shield Library is a comprehensive C++ library designed for time manipulation, formatting, and conversion. This library aims to provide a robust and flexible set of tools for handling various time-related tasks with ease.
Features
- Validation of dates and times
- Time and date formatting
- Time zone calculations
- Conversion between different time representations
- Utilities for time manipulation
Usage
#include <iostream>
int main() {
std::cout << "Days until end of year: " << days << std::endl;
std::string formatted_time = tsh::to_iso8601_str(future_ts);
std::cout << "Error occurred while parsing ISO8601 string" << std::endl;
return -1;
}
std::cout << "Future time: " << formatted_time << std::endl;
return 0;
}
constexpr const T get_days_difference(ts_t start, ts_t stop) noexcept
Get the number of days between two timestamps.
TIME_SHIELD_CONSTEXPR ts_t end_of_year(ts_t ts=ts())
Get the end-of-year timestamp.
const bool str_to_ts_ms(const std::string &str, ts_ms_t &ts)
Convert an ISO8601 string to a millisecond timestamp (ts_ms_t).
int64_t ts_t
Type for representing timestamps in seconds.
int64_t ts_ms_t
Type for representing timestamps in milliseconds.
const ts_t timestamp() noexcept
Get the current UTC timestamp in seconds.
Main header file for the Time Shield library.
Installation
To use the Time Shield Library in your project, include the header file time_shield.hpp
in your source code. Ensure that your project is set up to compile with standards from C++11 to C++17.
Repository
Time Shield Library GitHub repository.
License
This library is licensed under the MIT License. See the LICENSE file for more details.