diff --git a/statusweather.cpp b/statusweather.cpp index 6ffbd15..6e48fb2 100644 --- a/statusweather.cpp +++ b/statusweather.cpp @@ -36,6 +36,7 @@ #include #include #include +#include struct weather { @@ -48,22 +49,28 @@ std::mutex mutex_weather; std::string map_icon(const std::string_view icon_id) { // - const std::map icons{{{1, "🌞"}, - {2, "⛅"}, - {3, "☁"}, - {4, "☁"}, - {9, "🌧"}, - {10, "🌧"}, - {10, "⛈"}, - {13, "🌨"}, - {50, "🌫"}}}; - // TODO: Differenciate between day and night. + // NOTE: There does not seem to be weather emojis with the moon in unicode. + const std::map> icons{ + {{1, {"🌞", "🌝"}}, // clear sky + {2, {"🌤", "🌤"}}, // few clouds + {3, {"⛅", "⛅"}}, // scattered clouds + {4, {"☁", "☁"}}, // broken clouds + {9, {"🌧", "🌧"}}, // shower rain + {10, {"🌧", "🌧"}}, // rain + {10, {"🌩", "🌩"}}, // thunderstorm + {13, {"🌨", "🌨"}}, // snow + {50, {"🌫", "🌫"}}}}; // mist const auto icon{icons.find(std::stoul(icon_id.data()))}; + if (icon != icons.end()) { - return icon->second; + if (*icon_id.rbegin() == 'n') // Night + { + return icon->second.second; + } + return icon->second.first; } - return {}; + return "❔"; } std::tuple get_options()