Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/X-ARTEMIS/ASTD/llms.txt

Use this file to discover all available pages before exploring further.

The astd/time/time.hpp header exposes two functions inside the astd namespace for querying the current system clock. Both functions wrap the C++20 <chrono> facilities and offer an opt-in local flag that converts the result from UTC to the system’s local timezone. When local is false (the default), each function returns a standard std::chrono::system_clock::time_point suitable for serialisation, logging, or further <chrono> arithmetic.
#include "astd/time/time.hpp"
// or via the umbrella header:
#include "astd/astd.hpp"
Local timezone conversion (local = true) relies on the C++20 timezone database (std::chrono::current_zone). This requires a C++20-capable compiler and, on some platforms (notably MSVC before VS 2019 16.10 and certain Linux distros), a separately installed timezone data package. Confirm your toolchain supports <chrono> timezone facilities before using the local overloads.

astd::getSystemTime

Returns the current system clock time with full sub-second precision.
namespace astd {
    auto getSystemTime(const bool local = false);
}
Internally this calls std::chrono::system_clock::now(). When local is true, the result is passed through std::chrono::current_zone()->to_local(...) to produce a local-timezone time point.
local
bool
When false (default), returns a UTC std::chrono::system_clock::time_point. When true, converts the UTC time point to the host system’s local timezone using std::chrono::current_zone()->to_local(...).
time_point
std::chrono::system_clock::time_point (UTC) or local_time (local)
The current system time at whatever precision system_clock provides on the target platform (typically nanoseconds or microseconds). When local = true, the returned type is a std::chrono::local_time specialisation rather than a plain system_clock::time_point.

astd::getSystemTrimmedTime

Returns the current system clock time truncated to whole-second precision.
namespace astd {
    auto getSystemTrimmedTime(const bool local = false);
}
This function applies std::chrono::time_point_cast<std::chrono::seconds>(...) to strip the sub-second component before returning. Use it when you need timestamps that are clean for human-readable output, second-granularity logging, or comparisons where fractional seconds add noise.
Prefer getSystemTrimmedTime over getSystemTime when writing timestamps to a database or log file where millisecond-level jitter would produce misleading diffs between otherwise equivalent entries.
local
bool
When false (default), returns a UTC time point cast to second precision. When true, truncates first and then converts to the local timezone via std::chrono::current_zone()->to_local(...).
time_point
std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> (UTC) or local equivalent
The current system time with the sub-second remainder discarded. The duration tick period is guaranteed to be std::chrono::seconds.

Usage example

#include "astd/time/time.hpp"
#include <iostream>
#include <chrono>

int main() {
    // Full precision — UTC
    auto nowUtc = astd::getSystemTime();
    std::cout << "UTC (full):    " << nowUtc << '\n';

    // Second precision — UTC
    auto trimmedUtc = astd::getSystemTrimmedTime();
    std::cout << "UTC (trimmed): " << trimmedUtc << '\n';
}

Comparison of the two functions

getSystemTimegetSystemTrimmedTime
PrecisionFull (system_clock native)Seconds only
Sub-second dataPreservedDiscarded via time_point_cast
Typical use caseBenchmarking, profiling, high-res logsHuman-readable timestamps, second-granularity comparisons
Local timezoneSupported (local = true)Supported (local = true)
C++ standard requiredC++20 (for local = true)C++20 (for local = true)

Build docs developers (and LLMs) love