[time.zone.timezone]

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

## 30.11 Time zones [[time.zone]](time.zone#timezone)

### 30.11.5 Class time_zone [time.zone.timezone]

#### [30.11.5.1](#time.zone.overview) Overview [[time.zone.overview]](time.zone.overview)

namespace std::chrono {class time_zone {public: time_zone(time_zone&&) = default;
 time_zone& operator=(time_zone&&) = default; // unspecified additional constructors string_view name() const noexcept; template<class Duration> sys_info get_info(const sys_time<Duration>& st) const; template<class Duration> local_info get_info(const local_time<Duration>& tp) const; template<class Duration> sys_time<common_type_t<Duration, seconds>> to_sys(const local_time<Duration>& tp) const; template<class Duration> sys_time<common_type_t<Duration, seconds>> to_sys(const local_time<Duration>& tp, choose z) const; template<class Duration> local_time<common_type_t<Duration, seconds>> to_local(const sys_time<Duration>& tp) const; };}

[1](#time.zone.overview-1)

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

A time_zone represents all time zone transitions
for a specific geographic area[.](#time.zone.overview-1.sentence-1)

time_zone construction is unspecified,
and performed as part of database initialization[.](#time.zone.overview-1.sentence-2)

[*Note [1](#time.zone.overview-note-1)*:

const time_zone objects can be accessed
via functions such as locate_zone[.](#time.zone.overview-1.sentence-3)

â *end note*]

#### [30.11.5.2](#time.zone.members) Member functions [[time.zone.members]](time.zone.members)

[ð](#lib:name,time_zone)

`string_view name() const noexcept;
`

[1](#time.zone.members-1)

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

*Returns*: The name of the time_zone[.](#time.zone.members-1.sentence-1)

[2](#time.zone.members-2)

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

[*Example [1](#time.zone.members-example-1)*:

"America/New_York"[.](#time.zone.members-2.sentence-1)

â *end example*]

[ð](#lib:get_info,time_zone)

`template<class Duration>
  sys_info get_info(const sys_time<Duration>& st) const;
`

[3](#time.zone.members-3)

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

*Returns*: A sys_info i for whichst is in the range [i.begin, i.end)[.](#time.zone.members-3.sentence-1)

[ð](#lib:get_info,time_zone_)

`template<class Duration>
  local_info get_info(const local_time<Duration>& tp) const;
`

[4](#time.zone.members-4)

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

*Returns*: A local_info for tp[.](#time.zone.members-4.sentence-1)

[ð](#lib:to_sys,time_zone)

`template<class Duration>
  sys_time<common_type_t<Duration, seconds>>
    to_sys(const local_time<Duration>& tp) const;
`

[5](#time.zone.members-5)

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

*Returns*: A sys_time that is at least as fine as seconds,
and will be finer if the argument tp has finer precision[.](#time.zone.members-5.sentence-1)

This sys_time is the UTC equivalent of tp according to the rules of this time_zone[.](#time.zone.members-5.sentence-2)

[6](#time.zone.members-6)

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

*Throws*: If the conversion from tp to a sys_time is ambiguous,
throws ambiguous_local_time[.](#time.zone.members-6.sentence-1)

If the tp represents a non-existent time between two UTC time_points,
throws nonexistent_local_time[.](#time.zone.members-6.sentence-2)

[ð](#lib:to_sys,time_zone_)

`template<class Duration>
  sys_time<common_type_t<Duration, seconds>>
    to_sys(const local_time<Duration>& tp, choose z) const;
`

[7](#time.zone.members-7)

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

*Returns*: A sys_time that is at least as fine as seconds,
and will be finer if the argument tp has finer precision[.](#time.zone.members-7.sentence-1)

This sys_time is the UTC equivalent of tp according to the rules of this time_zone[.](#time.zone.members-7.sentence-2)

If the conversion from tp to a sys_time is ambiguous,
returns the earlier sys_time if z == choose​::​earliest, and
returns the later sys_time if z == choose​::​latest[.](#time.zone.members-7.sentence-3)

If the tp represents a non-existent time between two UTC time_points,
then the two UTC time_points will be the same,
and that UTC time_point will be returned[.](#time.zone.members-7.sentence-4)

[ð](#lib:to_local,time_zone)

`template<class Duration>
  local_time<common_type_t<Duration, seconds>>
    to_local(const sys_time<Duration>& tp) const;
`

[8](#time.zone.members-8)

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

*Returns*: The local_time associated with tp and this time_zone[.](#time.zone.members-8.sentence-1)

#### [30.11.5.3](#time.zone.nonmembers) Non-member functions [[time.zone.nonmembers]](time.zone.nonmembers)

[ð](#lib:operator==,time_zone)

`bool operator==(const time_zone& x, const time_zone& y) noexcept;
`

[1](#time.zone.nonmembers-1)

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

*Returns*: x.name() == y.name()[.](#time.zone.nonmembers-1.sentence-1)

[ð](#lib:operator%3c=%3e,time_zone)

`strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept;
`

[2](#time.zone.nonmembers-2)

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

*Returns*: x.name() <=> y.name()[.](#time.zone.nonmembers-2.sentence-1)
