DateHelper is a small C++17 date/time helper library built around std::chrono and the bundled Howard Hinnant date.h headers. The project provides a portable V2 API for:
- creating and formatting timestamps
- converting to and from
std::tm - carrying millisecond-aware date values in a simple shared struct
- computing signed time differences
- working with local time versus UTC safely
The repository focuses on the portable V2 headers:
cDateHelper_V2.hcDateHelper2_V2.hcDateHelperData_V2.h
The older DateHelper code path depended on COM/ATL DATE handling and was effectively Windows-only. The V2 API keeps the library usable under modern C++17 toolchains on macOS, Linux, and Windows.
- C++17 compiler
- bundled
date_h/date.h
No external package manager dependency is required for the V2 path.
cmake -S . -B build
cmake --build buildThis builds the example programs by default.
Include the front header:
#include "cDateHelper_V2.h"Create and format a timestamp:
auto candle = CDateTime_V2::EncodeDateTime(2026, 4, 3, 15, 30, 0, 250);
auto text = candle.ToStringFull(); // 2026/04/03 15:30:00.250Get signed differences:
auto start = CDateTime_V2::EncodeDateTime(2026, 4, 3, 15, 0, 0, 0);
auto end = CDateTime_V2::EncodeDateTime(2026, 4, 3, 15, 0, 1, 500);
auto seconds = end.GetSecondsSince(start, CDateTime_V2::Rounding::Floor);
auto millis = end.GetMilliSecondsSince(start);Use the shared data contract:
td_datetime_2_val_V2 payload;
payload.tm_year = 126; // years since 1900
payload.tm_mon = 3; // April (0-based)
payload.tm_mday = 3;
payload.tm_hour = 15;
payload.tm_min = 30;
payload.tm_sec = 0;
payload.tm_millisec = 250;
auto value = CDateTime2_V2::EncodeDateTime(payload);Runnable examples live in examples:
basicDateExample_V2.cpptimeReferenceExample_V2.cppdataContractExample_V2.cpp
Example binaries are built into the build directory:
./build/examples/basicDateExample_V2
./build/examples/timeReferenceExample_V2
./build/examples/dataContractExample_V2cDateHelper_V2.h: front include for the portable V2 APIcDateHelper2_V2.h: main chrono/date helper implementationcDateHelperData_V2.h: shared datetime payload structdate_h: bundled third-party date libraryexamples: usage examples
This project is licensed under the GNU GPL v3.0. Third-party components keep their own licenses; the bundled date.h sources remain under their upstream terms.