Skip to content

Commit

Permalink
Revert "[libc++][TZDB] Implements time_zone::to_sys. (llvm#90394)"
Browse files Browse the repository at this point in the history
This reverts commit 77116bd.
  • Loading branch information
fmayer committed Jun 10, 2024
1 parent 7eaf993 commit 9791e73
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 1,027 deletions.
1 change: 0 additions & 1 deletion 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 Down
129 changes: 0 additions & 129 deletions libcxx/include/__chrono/exception.h

This file was deleted.

27 changes: 0 additions & 27 deletions libcxx/include/__chrono/time_zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@

# 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 Down Expand Up @@ -72,31 +70,6 @@ class _LIBCPP_AVAILABILITY_TZDB time_zone {
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 {};
}

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

private:
Expand Down
9 changes: 0 additions & 9 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 @@ -770,10 +766,6 @@ class time_zone {
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;
};
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
Expand Down Expand Up @@ -923,7 +915,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
6 changes: 1 addition & 5 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,6 @@ module std_private_chrono_duration [system] {
header "__chrono/duration.h"
export std_private_type_traits_is_convertible
}
module std_private_chrono_exception [system] { header "__chrono/exception.h" }
module std_private_chrono_file_clock [system] { header "__chrono/file_clock.h" }
module std_private_chrono_formatter [system] {
header "__chrono/formatter.h"
Expand All @@ -1114,10 +1113,7 @@ module std_private_chrono_high_resolution_clock [system] {
}
module std_private_chrono_leap_second [system] { header "__chrono/leap_second.h" }
module std_private_chrono_literals [system] { header "__chrono/literals.h" }
module std_private_chrono_local_info [system] {
header "__chrono/local_info.h"
export std_private_chrono_sys_info
}
module std_private_chrono_local_info [system] { header "__chrono/local_info.h" }
module std_private_chrono_month [system] { header "__chrono/month.h" }
module std_private_chrono_month_weekday [system] { header "__chrono/month_weekday.h" }
module std_private_chrono_monthday [system] { header "__chrono/monthday.h" }
Expand Down
7 changes: 4 additions & 3 deletions libcxx/modules/std/chrono.inc
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,13 @@ export namespace std {
using std::chrono::reload_tzdb;
using std::chrono::remote_version;

# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&
// !defined(_LIBCPP_HAS_NO_LOCALIZATION)

# if 0
// [time.zone.exception], exception classes
using std::chrono::ambiguous_local_time;
using std::chrono::nonexistent_local_time;
# endif // if 0
# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&
// !defined(_LIBCPP_HAS_NO_LOCALIZATION)

// [time.zone.info], information classes
using std::chrono::local_info;
Expand Down
3 changes: 0 additions & 3 deletions libcxx/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,6 @@ if (LIBCXX_ENABLE_LOCALIZATION AND LIBCXX_ENABLE_FILESYSTEM AND LIBCXX_ENABLE_TI
include/tzdb/types_private.h
include/tzdb/tzdb_list_private.h
include/tzdb/tzdb_private.h
# TODO TZDB The exception could be moved in chrono once the TZDB library
# is no longer experimental.
chrono_exception.cpp
time_zone.cpp
tzdb.cpp
tzdb_list.cpp
Expand Down
22 changes: 0 additions & 22 deletions libcxx/src/chrono_exception.cpp

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9791e73

Please sign in to comment.