[time.duration.literals]

# 30 Time library [[time]](./#time)

## 30.5 Class template duration [[time.duration]](time.duration#literals)

### 30.5.9 Suffixes for duration literals [time.duration.literals]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1926)

This subclause describes literal suffixes for constructing duration literals[.](#1.sentence-1)

The
suffixes h, min, s, ms, us, ns denote duration values of the corresponding types hours, minutes,seconds, milliseconds, microseconds, and nanoseconds respectively if they are applied to [*integer-literal*](lex.icon#nt:integer-literal "5.13.2 Integer literals [lex.icon]")*s*[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1933)

If any of these suffixes are applied to a [*floating-point-literal*](lex.fcon#nt:floating-point-literal "5.13.4 Floating-point literals [lex.fcon]") the result is achrono​::​duration literal with an unspecified floating-point representation[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1938)

If any of these suffixes are applied to an [*integer-literal*](lex.icon#nt:integer-literal "5.13.2 Integer literals [lex.icon]") and the resultingchrono​::​duration value cannot be represented in the result type because
of overflow, the program is ill-formed[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1944)

[*Example [1](#example-1)*:

The following code shows some duration literals[.](#4.sentence-1)

using namespace std::chrono_literals;auto constexpr aday=24h;auto constexpr lesson=45min;auto constexpr halfanhour=0.5h; â *end example*]

[ð](#lib:operator%22%22h,duration)

`constexpr chrono::hours                                 operator""h(unsigned long long hours);
constexpr chrono::duration<unspecified, ratio<3600, 1>> operator""h(long double hours);
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1962)

*Returns*: A duration literal representing hours hours[.](#5.sentence-1)

[ð](#lib:operator%22%22min,duration)

`constexpr chrono::minutes                             operator""min(unsigned long long minutes);
constexpr chrono::duration<unspecified, ratio<60, 1>> operator""min(long double minutes);
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1974)

*Returns*: A duration literal representing minutes minutes[.](#6.sentence-1)

[ð](#lib:operator%22%22s,duration)

`constexpr chrono::seconds               operator""s(unsigned long long sec);
constexpr chrono::duration<unspecified> operator""s(long double sec);
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1986)

*Returns*: A duration literal representing sec seconds[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1990)

[*Note [1](#note-1)*:

The same suffix s is used for basic_string but there is no
conflict, since duration suffixes apply to numbers and string literal suffixes
apply to character array literals[.](#8.sentence-1)

â *end note*]

[ð](#lib:operator%22%22ms,duration)

`constexpr chrono::milliseconds                 operator""ms(unsigned long long msec);
constexpr chrono::duration<unspecified, milli> operator""ms(long double msec);
`

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2005)

*Returns*: A duration literal representing msec milliseconds[.](#9.sentence-1)

[ð](#lib:operator%22%22us,duration)

`constexpr chrono::microseconds                 operator""us(unsigned long long usec);
constexpr chrono::duration<unspecified, micro> operator""us(long double usec);
`

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2017)

*Returns*: A duration literal representing usec microseconds[.](#10.sentence-1)

[ð](#lib:operator%22%22ns,duration)

`constexpr chrono::nanoseconds                 operator""ns(unsigned long long nsec);
constexpr chrono::duration<unspecified, nano> operator""ns(long double nsec);
`

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2029)

*Returns*: A duration literal representing nsec nanoseconds[.](#11.sentence-1)
