From dbd0829e61f541b787cc353a3caabf23bfa065ef Mon Sep 17 00:00:00 2001 From: Scott Gilbertson Date: Mon, 12 Feb 2024 18:35:01 -0500 Subject: [PATCH] Obtain the export, shooting or save time, per letter after %t output template specifier Print the result (not yet processing a time formatting string) --- rtgui/batchqueue.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index 2811e3445..8654ce45e 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -18,8 +18,10 @@ */ #include #include +#include #include #include +#include "../rtengine/imagedata.h" #include "../rtengine/rt_math.h" #include "../rtengine/procparams.h" @@ -1001,6 +1003,45 @@ Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileNam seqstr << sequence; path += seqstr.str (); + } else if (options.savePathTemplate[ix] == 't') { + // Insert formatted date/time value. Character after 't' defines time source + if (++ix < options.savePathTemplate.size()) + { + Glib::DateTime dateTime; + bool dateTimeIsValid = true; + switch(options.savePathTemplate[ix]) + { + case 'E': // (approximate) time when export started + dateTime = Glib::DateTime::create_now_local(); + break; + case 'F': // time when file was last saved + { + struct stat fileStat; + if (stat(origFileName.c_str(), &fileStat) == 0) { + time_t timestamp = fileStat.st_mtime; + dateTime = Glib::DateTime::create_now_local(timestamp); + } else { + dateTimeIsValid = false; // file not found, access denied, etc. + } + } + break; + case 'P': // time when picture was taken + { + auto timestamp = FramesData(origFileName).getDateTimeAsTS(); + dateTime = Glib::DateTime::create_now_local(timestamp); + } + break; + default: + dateTimeIsValid = false; + break; + } + if (dateTimeIsValid) + { + // FIXME: Call a function that looks for a double-quoted format string, and + // format dateTime accordingly, adding it to path. + printf("Time %s\n", dateTime.format_iso8601().c_str()); + } + } } }