Skip to content

Chrono literals

Header: chrono.h
From: 20.41.0
Similar to: std::literals::chrono_literals

The ETL Chrono literals are define slightly differently from the STL in that they are user defined, as opposed to language defined.

Example
For STL, the literal to define year 2025 would be 2025y. For ETL, the literal is 2025_y.

By default, the ETL uses the designations of the STL.
As this may clash with other user defined literals, the ETL allows more verbose forms to be used, by defining the macro ETL_USE_VERBOSE_CHRONO_LITERALS.
If enabled, the example of 2025_y would be written as 2025_year.

Duration typeSTL likeVerbose
etl::chrono::year2025_y2025_year
etl::chrono::day10_d10_day
etl::chrono::hours14_h14_hours
etl::chrono::minutes30_min30_minutes
etl::chrono::seconds45_s45_seconds
etl::chrono::milliseconds500_ms500_milliseconds
etl::chrono::microseconds500_us500_microseconds
etl::chrono::nanoseconds500_ns500_nanoseconds

Chrono literals may by accessed by using one of the following namespaces.

using namespace etl::chrono;
using namespace etl::literals;
using namespace etl::chrono_literals;