Fix deprecated ftm::localtime

This commit is contained in:
Georg Hagen
2025-08-12 14:55:55 +02:00
parent 8cf597f7e8
commit f08bd0dec3
6 changed files with 4 additions and 24 deletions

View File

@@ -9,6 +9,7 @@ FetchContent_Declare(
GIT_REPOSITORY ${BROTLI_REPO} GIT_REPOSITORY ${BROTLI_REPO}
GIT_TAG v1.1.0 GIT_TAG v1.1.0
GIT_SHALLOW TRUE GIT_SHALLOW TRUE
EXCLUDE_FROM_ALL
) )
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)

View File

@@ -11,4 +11,6 @@ FetchContent_Declare(
GIT_TAG v0.9.0 GIT_TAG v0.9.0
GIT_SHALLOW FALSE # ensure submodules are checked out GIT_SHALLOW FALSE # ensure submodules are checked out
) )
set(C4CORE_INSTALL OFF CACHE BOOL "" FORCE)
set(RYML_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(ryml) FetchContent_MakeAvailable(ryml)

View File

@@ -311,11 +311,6 @@ namespace OpenVulkano::Image
altitude = std::abs(level); altitude = std::abs(level);
} }
void ExifBuilder::SetTime(std::time_t timestamp)
{
dateTaken = StringFromTime(timestamp);
}
std::vector<uint8_t> ExifBuilder::Build() std::vector<uint8_t> ExifBuilder::Build()
{ {
std::vector<uint8_t> result; std::vector<uint8_t> result;
@@ -487,15 +482,9 @@ namespace OpenVulkano::Image
return result; return result;
} }
std::string ExifBuilder::StringFromTime(std::time_t time)
{
return fmt::format("{:%Y:%m:%d %H:%M:%S}", fmt::localtime(time));
}
std::string ExifBuilder::GetCurrentTimestamp() std::string ExifBuilder::GetCurrentTimestamp()
{ {
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
std::time_t currentTime = std::chrono::system_clock::to_time_t(now); return fmt::format("{:%Y:%m:%d %H:%M:%S}", now); // TODO convert to local time
return StringFromTime(currentTime);
} }
} }

View File

@@ -87,10 +87,8 @@ namespace OpenVulkano::Image
void SetResolution(uint32_t dpi = 72) { xResolution = yResolution = dpi; resolutionUnit = 2;} void SetResolution(uint32_t dpi = 72) { xResolution = yResolution = dpi; resolutionUnit = 2;}
void SetOrientation(float orientationRad); void SetOrientation(float orientationRad);
void SetTime(std::time_t timestamp);
// Typical usage is -> jpeg_write_marker(cinfo, JPEG_APP0 + 1, exif_data.data(), exif_data.size()); // Typical usage is -> jpeg_write_marker(cinfo, JPEG_APP0 + 1, exif_data.data(), exif_data.size());
[[nodiscard]] std::vector<uint8_t> Build(); [[nodiscard]] std::vector<uint8_t> Build();
[[nodiscard]] static std::string StringFromTime(std::time_t time);
[[nodiscard]] static std::string GetCurrentTimestamp(); [[nodiscard]] static std::string GetCurrentTimestamp();
}; };
} }

View File

@@ -105,15 +105,6 @@ namespace OpenVulkano::Image
return SetCreateDate(fmt::format("{:%FT%T%Ez}", std::chrono::system_clock::now())); return SetCreateDate(fmt::format("{:%FT%T%Ez}", std::chrono::system_clock::now()));
} }
[[maybe_unused]] XmpBuilder& XmpBuilder::SetCreateDate(const std::time_t time)
{
#ifdef WIN32
return SetCreateDate(fmt::format("{:%FT%T%Ez}", std::chrono::system_clock::from_time_t(time)));
#else
return SetCreateDate(fmt::format("{:%FT%T%Ez}", fmt::localtime(time)));
#endif
}
[[maybe_unused]] XmpBuilder& XmpBuilder::SetCreateDate(const std::string& createDate) [[maybe_unused]] XmpBuilder& XmpBuilder::SetCreateDate(const std::string& createDate)
{ {
xmpData << "<xmp:CreateDate>" << createDate << "</xmp:CreateDate>"; xmpData << "<xmp:CreateDate>" << createDate << "</xmp:CreateDate>";

View File

@@ -30,7 +30,6 @@ namespace OpenVulkano::Image
[[maybe_unused]] XmpBuilder& SetFocalLength(float focalLengthMM); [[maybe_unused]] XmpBuilder& SetFocalLength(float focalLengthMM);
[[maybe_unused]] XmpBuilder& SetExposureTime(double exposureTime); [[maybe_unused]] XmpBuilder& SetExposureTime(double exposureTime);
[[maybe_unused]] XmpBuilder& SetCreateDateNow(); [[maybe_unused]] XmpBuilder& SetCreateDateNow();
[[maybe_unused]] XmpBuilder& SetCreateDate(const std::time_t time);
[[maybe_unused]] XmpBuilder& SetCreateDate(const std::string& createDate); [[maybe_unused]] XmpBuilder& SetCreateDate(const std::string& createDate);
[[maybe_unused]] std::string Close() { return Finalize(); } [[maybe_unused]] std::string Close() { return Finalize(); }