Skip to content

Reverts around time_zone #95058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ set(files
__chrono/convert_to_tm.h
__chrono/day.h
__chrono/duration.h
__chrono/exception.h
__chrono/file_clock.h
__chrono/formatter.h
__chrono/hh_mm_ss.h
Expand All @@ -277,7 +276,6 @@ set(files
__chrono/year_month.h
__chrono/year_month_day.h
__chrono/year_month_weekday.h
__chrono/zoned_time.h
__compare/common_comparison_category.h
__compare/compare_partial_order_fallback.h
__compare/compare_strong_order_fallback.h
Expand Down
129 changes: 0 additions & 129 deletions libcxx/include/__chrono/exception.h

This file was deleted.

85 changes: 0 additions & 85 deletions libcxx/include/__chrono/time_zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)

# include <__chrono/calendar.h>
# include <__chrono/duration.h>
# include <__chrono/exception.h>
# include <__chrono/local_info.h>
# include <__chrono/sys_info.h>
# include <__chrono/system_clock.h>
# include <__compare/strong_order.h>
# include <__config>
# include <__memory/unique_ptr.h>
# include <__type_traits/common_type.h>
# include <string_view>

# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand All @@ -42,8 +38,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD

namespace chrono {

enum class choose { earliest, latest };

class _LIBCPP_AVAILABILITY_TZDB time_zone {
_LIBCPP_HIDE_FROM_ABI time_zone() = default;

Expand All @@ -69,91 +63,12 @@ class _LIBCPP_AVAILABILITY_TZDB time_zone {
return __get_info(chrono::time_point_cast<seconds>(__time));
}

template <class _Duration>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_info get_info(const local_time<_Duration>& __time) const {
return __get_info(chrono::time_point_cast<seconds>(__time));
}

// We don't apply nodiscard here since this function throws on many inputs,
// so it could be used as a validation.
template <class _Duration>
_LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>> to_sys(const local_time<_Duration>& __time) const {
local_info __info = get_info(__time);
switch (__info.result) {
case local_info::unique:
return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset};

case local_info::nonexistent:
chrono::__throw_nonexistent_local_time(__time, __info);

case local_info::ambiguous:
chrono::__throw_ambiguous_local_time(__time, __info);
}

// TODO TZDB The Standard does not specify anything in these cases.
_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__info.result != -1, "cannot convert the local time; it would be before the minimum system clock value");
_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__info.result != -2, "cannot convert the local time; it would be after the maximum system clock value");

return {};
}

template <class _Duration>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>>
to_sys(const local_time<_Duration>& __time, choose __z) const {
local_info __info = get_info(__time);
switch (__info.result) {
case local_info::unique:
case local_info::nonexistent: // first and second are the same
return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset};

case local_info::ambiguous:
switch (__z) {
case choose::earliest:
return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset};

case choose::latest:
return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.second.offset};

// Note a value out of bounds is not specified.
}
}

// TODO TZDB The standard does not specify anything in these cases.
_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__info.result != -1, "cannot convert the local time; it would be before the minimum system clock value");
_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__info.result != -2, "cannot convert the local time; it would be after the maximum system clock value");

return {};
}

template <class _Duration>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time<common_type_t<_Duration, seconds>>
to_local(const sys_time<_Duration>& __time) const {
using _Dp = common_type_t<_Duration, seconds>;

sys_info __info = get_info(__time);

_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__info.offset >= chrono::seconds{0} || __time.time_since_epoch() >= _Dp::min() - __info.offset,
"cannot convert the system time; it would be before the minimum local clock value");

_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__info.offset <= chrono::seconds{0} || __time.time_since_epoch() <= _Dp::max() - __info.offset,
"cannot convert the system time; it would be after the maximum local clock value");

return local_time<_Dp>{__time.time_since_epoch() + __info.offset};
}

[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const __impl& __implementation() const noexcept { return *__impl_; }

private:
[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI string_view __name() const noexcept;

[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI sys_info __get_info(sys_seconds __time) const;
[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info __get_info(local_seconds __time) const;

unique_ptr<__impl> __impl_;
};
Expand Down
55 changes: 0 additions & 55 deletions libcxx/include/__chrono/zoned_time.h

This file was deleted.

24 changes: 0 additions & 24 deletions libcxx/include/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,6 @@ const time_zone* current_zone()
const tzdb& reload_tzdb(); // C++20
string remote_version(); // C++20

// [time.zone.exception], exception classes
class nonexistent_local_time; // C++20
class ambiguous_local_time; // C++20

// [time.zone.info], information classes
struct sys_info { // C++20
sys_seconds begin;
Expand Down Expand Up @@ -767,28 +763,10 @@ class time_zone {

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;
};
bool operator==(const time_zone& x, const time_zone& y) noexcept; // C++20
strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept; // C++20

// [time.zone.zonedtraits], class template zoned_traits
template<class T> struct zoned_traits; // C++20

// [time.zone.leap], leap second support
class leap_second { // C++20
public:
Expand Down Expand Up @@ -934,7 +912,6 @@ constexpr chrono::year operator ""y(unsigned lo
#if _LIBCPP_STD_VER >= 20
# include <__chrono/calendar.h>
# include <__chrono/day.h>
# include <__chrono/exception.h>
# include <__chrono/hh_mm_ss.h>
# include <__chrono/literals.h>
# include <__chrono/local_info.h>
Expand Down Expand Up @@ -962,7 +939,6 @@ constexpr chrono::year operator ""y(unsigned lo
# include <__chrono/time_zone_link.h>
# include <__chrono/tzdb.h>
# include <__chrono/tzdb_list.h>
# include <__chrono/zoned_time.h>
# endif

#endif
Expand Down
Loading
Loading