mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(clock): support chrono Time Zone extensions.
Use chrono Calendars and Time Zones (P0355R7, P1466R3) when available instead of the `date` library. Verified with a patched build of a recent GCC 13 snapshot.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <json/json.h>
|
||||
#ifdef HAVE_LIBDATE
|
||||
#if defined(HAVE_CHRONO_TIMEZONES) || defined(HAVE_LIBDATE)
|
||||
#include "modules/clock.hpp"
|
||||
#else
|
||||
#include "modules/simpleclock.hpp"
|
||||
|
@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <date/tz.h>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/date.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
@ -1,8 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <date/tz.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#if HAVE_CHRONO_TIMEZONES
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
|
||||
/* Compatibility layer for <date/tz.h> on top of C++20 <chrono> */
|
||||
namespace date {
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
namespace literals {
|
||||
using std::chrono::last;
|
||||
}
|
||||
|
||||
inline auto format(const std::string& spec, const auto& ztime) {
|
||||
return spec.empty() ? "" : std::vformat("{:L" + spec + "}", std::make_format_args(ztime));
|
||||
}
|
||||
|
||||
inline auto format(const std::locale& loc, const std::string& spec, const auto& ztime) {
|
||||
return spec.empty() ? "" : std::vformat(loc, "{:L" + spec + "}", std::make_format_args(ztime));
|
||||
}
|
||||
|
||||
} // namespace date
|
||||
|
||||
#else
|
||||
#include <date/tz.h>
|
||||
#endif
|
||||
|
||||
template <typename Duration, typename TimeZonePtr>
|
||||
struct fmt::formatter<date::zoned_time<Duration, TimeZonePtr>> {
|
||||
std::string_view specs;
|
||||
|
Reference in New Issue
Block a user