diff --git a/libs/indexer/editable_map_object.cpp b/libs/indexer/editable_map_object.cpp index 7bec87943..d8efaddbc 100644 --- a/libs/indexer/editable_map_object.cpp +++ b/libs/indexer/editable_map_object.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include namespace osm { @@ -42,6 +44,14 @@ bool ExtractName(StringUtf8Multilang const & names, int8_t const langCode, vecto return true; } +std::string GetCurrentDate() +{ + auto const t = std::time(nullptr); + auto const tm = *std::localtime(&t); + std::ostringstream oss; + oss << std::put_time(&tm, "%Y-%m-%d"); + return oss.str(); +} } // namespace // LocalizedName ----------------------------------------------------------------------------------- @@ -851,6 +861,25 @@ void EditableMapObject::ApplyJournalEntry(JournalEntry const & entry) void EditableMapObject::LogDiffInJournal(EditableMapObject const & unedited_emo) { LOG(LDEBUG, ("Executing LogDiffInJournal")); + + // Auto-fill check_date + if (ftypes::IsCheckDateChecker::Instance()(GetTypes())) + { + std::string const currentDate = GetCurrentDate(); + + // Always update check_date + SetMetadata(feature::Metadata::FMD_CHECK_DATE, currentDate); + + // Update check_date:opening_hours if Opening Hours changed + std::string_view const newOH = GetMetadata(feature::Metadata::FMD_OPEN_HOURS); + std::string_view const oldOH = unedited_emo.GetMetadata(feature::Metadata::FMD_OPEN_HOURS); + + // If new OH exists and is different from old (or old was empty), update the date. + if (!newOH.empty() && newOH != oldOH) + { + SetMetadata(feature::Metadata::FMD_CHECK_DATE_OPEN_HOURS, currentDate); + } + } // Name for (StringUtf8Multilang::Lang language : StringUtf8Multilang::GetSupportedLanguages())