userver: utils::datetime::TimeOfDay< Duration > Class Template Reference
Loading...
Searching...
No Matches
utils::datetime::TimeOfDay< Duration > Class Template Reference

Detailed Description

template<typename Duration>
class utils::datetime::TimeOfDay< Duration >

A simple implementation of a "time since midnight" datatype.

This type is time-zone ignorant.

Valid time range is from [00:00:00.0, 24:00:00.0)

Available construction:

from duration (since midnight, the value will be normalized, e.g. 25:00 will become 01:00, 24:00 will become 00:00)

from string representation HH:MM[:SS[.s]], accepted range is from 00:00 to 24:00

construction from int in form 1300 as a static member function

Accessors:

int Hours(); // hours since midnight int Minutes(); // minutes since midnight + Hours() int Seconds(); // seconds since midnight + Hours() + Minutes() int Subseconds(); // seconds fraction since midnight + Hours() + Minutes() + Seconds()

Output:

LOG(xxx) << val

Formatting:

fmt::format("{}", val)

Default format for hours and minutes is HH:MM, for seconds HH:MM:SS, for subseconds HH:MM:SS.s with fractional part, but truncating trailing zeros.

Custom formatting:

fmt:format("{:%H%M%S}", val); // will output HHMMSS without separators

Format keys: H 24-hour two-digit zero-padded hours M two-digit zero-padded minutes S two-digit zero-padded seconds %% literal %

Definition at line 74 of file time_of_day.hpp.


The documentation for this class was generated from the following file: