.. Copyright (c) 2026 Tobias Erbsland - Erbsland DEV. https://erbsland.dev SPDX-License-Identifier: Apache-2.0 .. index:: single: Times; Working with Times single: Time; Wall-Clock Times single: Time; Midnight Wrapping ****************** Working with Times ****************** A time of day describes a position on a daily clock, independently of a date or time zone. :cpp:class:`Time ` represents that reading with nanosecond precision, from midnight to just before the next midnight. This page explains how to construct and compare times, access their clock fields, and convert them while choosing the precision you need. You will also learn how to calculate across midnight and retain the crossed days when working with a :doc:`date `. A Clock Reading Within One Day ============================== ``Time`` covers ``00:00:00`` through ``23:59:59.999999999`` with nanosecond resolution. Hours run from 0 to 23, and minutes and seconds from 0 to 59. The fraction belongs to the current second and runs from 0 to 999,999,999 nanoseconds. There is no separate representation for ``24:00:00`` or a leap second with second number 60. A ``Time`` has no date or time zone, so ``23:45`` is simply a position on a 24-hour clock. It does not establish which day you mean or whether the clock is showing UTC or local time. The nanosecond resolution lets it preserve a fine fractional reading; it does not imply that your source clock can measure every nanosecond accurately. Every ``Time`` is a valid time within the day. Default construction gives midnight, and :cpp:func:`isZero() ` tests for that exact value, including a zero fraction. Unlike ``Date``, ``Time`` has no invalid sentinel and does not provide an ``isValid()`` test. If input may be missing, keep that absence separately, for example in a ``std::optional