From 6232d13f5321b87ddf12a1aa36b4545da45f173d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 17 Nov 2021 22:34:57 +0100 Subject: Travel3: Simple image and video display site Reads the images and videos from filesystem and builds a site in memroy. --- src/timezone.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/timezone.cc (limited to 'src/timezone.cc') diff --git a/src/timezone.cc b/src/timezone.cc new file mode 100644 index 0000000..ca0f501 --- /dev/null +++ b/src/timezone.cc @@ -0,0 +1,38 @@ +#include "common.hh" + +#include "geo_json.hh" +#include "timezone.hh" +#include "tz_info.hh" + +namespace { + +class TimezoneImpl : public Timezone { +public: + TimezoneImpl(std::shared_ptr logger, + std::filesystem::path geojsondb, + std::filesystem::path tzinfo_dir) + : geojson_(GeoJson::create(logger, std::move(geojsondb))), + tzinfo_(TzInfo::create(logger, std::move(tzinfo_dir))) { + } + + std::optional get_local_time(double lat, double lng, + time_t utc_time) const override { + auto tzid = geojson_->get_data(lat, lng, "tzid"); + if (tzid.has_value()) + return tzinfo_->get_local_time(tzid.value(), utc_time); + return std::nullopt; + } + +private: + std::unique_ptr geojson_; + std::unique_ptr tzinfo_; +}; + +} // namespace + +std::unique_ptr Timezone::create(std::shared_ptr logger, + std::filesystem::path geojsondb, + std::filesystem::path tzinfo_dir) { + return std::make_unique(std::move(logger), std::move(geojsondb), + std::move(tzinfo_dir)); +} -- cgit v1.2.3-70-g09d2