Constructs a Duration from an integral number of nanoseconds.

Synopsis

Declared in <absl/time/time.h>

template<
    typename T,
    /* implementation-defined */ = 0>
constexpr
Duration
Nanoseconds(T n);

Description

Factory functions for constructing Duration values from an integral number of the unit indicated by the factory function's name. The number must be representable as int64_t.

NOTE: no "Days()" factory function exists because "a day" is ambiguous. Civil days are not always 24 hours long, and a 24‐hour duration often does not correspond with a civil day. If a 24‐hour duration is needed, use absl::Hours(24). If you actually want a civil day, use absl::CivilDay from civil_time.h.

Example:

absl::Duration a = absl::Seconds(60); absl::Duration b = absl::Minutes(1); // b == a

Return Value

A duration of n nanoseconds.

Parameters

Name

Description

n

The number of nanoseconds.

Created with MrDocs