|
| 1 | +--- a/src/content/import_service.cc |
| 2 | ++++ b/src/content/import_service.cc |
| 3 | +@@ -800,7 +800,7 @@ void ImportService::parseMetafile(const |
| 4 | + void ImportService::updateItemData(const std::shared_ptr<CdsItem>& item, const std::string& mimetype) |
| 5 | + { |
| 6 | + if (hasDefaultDate && item->getMetaData(MetadataFields::M_DATE).empty()) |
| 7 | +- item->addMetaData(MetadataFields::M_DATE, fmt::format("{:%FT%T%z}", fmt::localtime(item->getMTime().count()))); |
| 8 | ++ item->addMetaData(MetadataFields::M_DATE, fmt::format("{:%FT%T%z}", fmt_localtime(item->getMTime().count()))); |
| 9 | + for (auto&& upnpPattern : upnpMap) { |
| 10 | + if (upnpPattern.isMatch(item, mimetype)) { |
| 11 | + item->setClass(upnpPattern.upnpClass); |
| 12 | +--- a/src/content/scripting/script.cc |
| 13 | ++++ b/src/content/scripting/script.cc |
| 14 | +@@ -237,7 +237,7 @@ Script::Script(const std::shared_ptr<Con |
| 15 | + setIntProperty(definition->removeAttribute(ConfigVal::A_AUTOSCAN_DIRECTORY_SCANCOUNT), adir->getActiveScanCount()); |
| 16 | + setIntProperty(definition->removeAttribute(ConfigVal::A_AUTOSCAN_DIRECTORY_TASKCOUNT), adir->getTaskCount()); |
| 17 | + setIntProperty(definition->removeAttribute(ConfigVal::A_AUTOSCAN_DIRECTORY_RETRYCOUNT), adir->getRetryCount()); |
| 18 | +- setProperty(definition->removeAttribute(ConfigVal::A_AUTOSCAN_DIRECTORY_LMT), fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(adir->getPreviousLMT().count()))); |
| 19 | ++ setProperty(definition->removeAttribute(ConfigVal::A_AUTOSCAN_DIRECTORY_LMT), fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt_localtime(adir->getPreviousLMT().count()))); |
| 20 | + |
| 21 | + duk_put_prop_string(ctx, -2, fmt::to_string(adir->getScanID()).c_str()); |
| 22 | + log_debug("Adding config[{}][{}] {}", autoscanItemPath, adir->getScanID(), adir->getLocation().string()); |
| 23 | +--- a/src/database/sql_database.cc |
| 24 | ++++ b/src/database/sql_database.cc |
| 25 | +@@ -1456,7 +1456,7 @@ int SQLDatabase::ensurePathExistence(con |
| 26 | + *changedContainer = parentID; |
| 27 | + |
| 28 | + std::vector<std::pair<std::string, std::string>> itemMetadata; |
| 29 | +- itemMetadata.emplace_back(MetaEnumMapper::getMetaFieldName(MetadataFields::M_DATE), fmt::format("{:%FT%T%z}", fmt::localtime(toSeconds(fs::last_write_time(path)).count()))); |
| 30 | ++ itemMetadata.emplace_back(MetaEnumMapper::getMetaFieldName(MetadataFields::M_DATE), fmt::format("{:%FT%T%z}", fmt_localtime(toSeconds(fs::last_write_time(path)).count()))); |
| 31 | + |
| 32 | + auto f2i = converterManager->f2i(); |
| 33 | + auto [mval, err] = f2i->convert(path.filename()); |
| 34 | +@@ -1654,7 +1654,7 @@ bool SQLDatabase::addContainer(int paren |
| 35 | + commit("addContainer"); |
| 36 | + |
| 37 | + if (cont->getMetaData(MetadataFields::M_DATE).empty()) |
| 38 | +- cont->addMetaData(MetadataFields::M_DATE, fmt::format("{:%FT%T%z}", fmt::localtime(cont->getMTime().count()))); |
| 39 | ++ cont->addMetaData(MetadataFields::M_DATE, fmt::format("{:%FT%T%z}", fmt_localtime(cont->getMTime().count()))); |
| 40 | + |
| 41 | + *containerID = createContainer(parentContainerId, cont->getTitle(), virtualPath, cont->getFlags(), cont->isVirtual(), cont->getClass(), cont->getFlag(OBJECT_FLAG_PLAYLIST_REF) ? cont->getRefID() : INVALID_OBJECT_ID, cont->getMetaData(), cont->getResources()); |
| 42 | + return true; |
| 43 | +@@ -2596,7 +2596,7 @@ std::vector<std::map<std::string, std::s |
| 44 | + stats["name"] = row->col(0); |
| 45 | + stats["count"] = fmt::format("{}", row->col_int(1, -1)); |
| 46 | + stats["playCount"] = fmt::format("{}", row->col_int(2, -1)); |
| 47 | +- stats["last"] = fmt::format("{:%a %b %d %H:%M:%S %Y}", fmt::localtime(std::chrono::seconds(row->col_int(3, 0)).count())); |
| 48 | ++ stats["last"] = fmt::format("{:%a %b %d %H:%M:%S %Y}", fmt_localtime(std::chrono::seconds(row->col_int(3, 0)).count())); |
| 49 | + stats["bookmarks"] = fmt::format("{}", row->col_int(4, -1)); |
| 50 | + result.push_back(std::move(stats)); |
| 51 | + } |
| 52 | +@@ -2725,7 +2725,7 @@ std::shared_ptr<AutoscanDirectory> SQLDa |
| 53 | + interval = std::stoi(getCol(row, AutoscanColumn::Interval)); |
| 54 | + auto lastModified = std::chrono::seconds(std::stol(getCol(row, AutoscanColumn::LastModified))); |
| 55 | + |
| 56 | +- log_info("Loading autoscan location: {}; recursive: {}, mt: {}/{}, last_modified: {}", location.c_str(), recursive, mt, AutoscanDirectory::mapMediaType(mt), lastModified > std::chrono::seconds::zero() ? fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(lastModified.count())) : "unset"); |
| 57 | ++ log_info("Loading autoscan location: {}; recursive: {}, mt: {}/{}, last_modified: {}", location.c_str(), recursive, mt, AutoscanDirectory::mapMediaType(mt), lastModified > std::chrono::seconds::zero() ? fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt_localtime(lastModified.count())) : "unset"); |
| 58 | + |
| 59 | + auto dir = std::make_shared<AutoscanDirectory>(location, mode, recursive, persistent, interval, hidden, followSymlinks, mt, containerMap); |
| 60 | + dir->setObjectID(objectID); |
| 61 | +--- a/src/metadata/ffmpeg_handler.cc |
| 62 | ++++ b/src/metadata/ffmpeg_handler.cc |
| 63 | +@@ -302,7 +302,7 @@ void FfmpegHandler::addFfmpegMetadataFie |
| 64 | + if (utcTime == -1) { |
| 65 | + continue; |
| 66 | + } |
| 67 | +- tmWork = fmt::localtime(utcTime); |
| 68 | ++ tmWork = fmt_localtime(utcTime); |
| 69 | + } else if (strptime(avEntry->value, "%Y-%m-%d", &tmWork)) { |
| 70 | + ; // use the value as is |
| 71 | + } else if (strptime(avEntry->value, "%Y", &tmWork)) { |
| 72 | +--- a/src/upnp/xml_builder.cc |
| 73 | ++++ b/src/upnp/xml_builder.cc |
| 74 | +@@ -45,6 +45,7 @@ |
| 75 | + #include "request_handler/device_description_handler.h" |
| 76 | + #include "request_handler/request_handler.h" |
| 77 | + #include "upnp/clients.h" |
| 78 | ++#include "util/tools.h" |
| 79 | + #include "util/url_utils.h" |
| 80 | + |
| 81 | + #include <algorithm> |
| 82 | +@@ -454,7 +455,7 @@ void UpnpXMLBuilder::renderObject( |
| 83 | + auto playStatus = item->getPlayStatus(); |
| 84 | + if (playStatus) { |
| 85 | + auxData[UPNP_SEARCH_PLAY_COUNT] = fmt::format("{}", playStatus->getPlayCount()); |
| 86 | +- auxData[UPNP_SEARCH_LAST_PLAYED] = fmt::format("{:%Y-%m-%d T %H:%M:%S}", fmt::localtime(playStatus->getLastPlayed().count())); |
| 87 | ++ auxData[UPNP_SEARCH_LAST_PLAYED] = fmt::format("{:%Y-%m-%d T %H:%M:%S}", fmt_localtime(playStatus->getLastPlayed().count())); |
| 88 | + auxData["upnp:lastPlaybackPosition"] = fmt::format("{}", millisecondsToHMSF(playStatus->getLastPlayedPosition().count())); |
| 89 | + propNames.push_back(addField(result, objFilter, UPNP_SEARCH_PLAY_COUNT, auxData[UPNP_SEARCH_PLAY_COUNT])); |
| 90 | + propNames.push_back(addField(result, objFilter, UPNP_SEARCH_LAST_PLAYED, auxData[UPNP_SEARCH_LAST_PLAYED])); |
| 91 | +@@ -490,7 +491,7 @@ void UpnpXMLBuilder::renderObject( |
| 92 | + // make sure a date is set |
| 93 | + auto dateNode = result.child(DC_DATE); |
| 94 | + if (!dateNode) { |
| 95 | +- auto fDate = fmt::format("{:%FT%T%z}", fmt::localtime(obj->getMTime().count())); |
| 96 | ++ auto fDate = fmt::format("{:%FT%T%z}", fmt_localtime(obj->getMTime().count())); |
| 97 | + if (simpleDate) |
| 98 | + fDate = makeSimpleDate(fDate); |
| 99 | + result.append_child(DC_DATE).append_child(pugi::node_pcdata).set_value(fDate.c_str()); |
| 100 | +--- a/src/util/tools.h |
| 101 | ++++ b/src/util/tools.h |
| 102 | +@@ -39,6 +39,7 @@ |
| 103 | + #include <optional> |
| 104 | + #include <string> |
| 105 | + #include <vector> |
| 106 | ++#include <ctime> |
| 107 | + |
| 108 | + // forward declaration |
| 109 | + class IOHandler; |
| 110 | +@@ -206,4 +207,10 @@ std::vector<std::string> populateCommand |
| 111 | + /// \return Caclulated position or -1 in case of an error. |
| 112 | + ssize_t getValidUTF8CutPosition(std::string_view str, ssize_t cutpos); |
| 113 | + |
| 114 | ++static inline std::tm fmt_localtime(std::time_t t) { |
| 115 | ++ std::tm tm_ = {}; |
| 116 | ++ localtime_r(&t, &tm_); |
| 117 | ++ return tm_; |
| 118 | ++} |
| 119 | ++ |
| 120 | + #endif // __TOOLS_H__ |
| 121 | +--- a/src/web/clients.cc |
| 122 | ++++ b/src/web/clients.cc |
| 123 | +@@ -34,13 +34,14 @@ |
| 124 | + #include "upnp/clients.h" |
| 125 | + #include "upnp/xml_builder.h" |
| 126 | + #include "util/grb_net.h" |
| 127 | ++#include "util/tools.h" |
| 128 | + #include "util/xml_to_json.h" |
| 129 | + |
| 130 | + #include <fmt/chrono.h> |
| 131 | + |
| 132 | + static std::string secondsToString(const std::chrono::seconds& t) |
| 133 | + { |
| 134 | +- return fmt::format("{:%a %b %d %H:%M:%S %Y}", fmt::localtime(t.count())); |
| 135 | ++ return fmt::format("{:%a %b %d %H:%M:%S %Y}", fmt_localtime(t.count())); |
| 136 | + } |
| 137 | + |
| 138 | + const std::string_view Web::Clients::PAGE = "clients"; |
| 139 | +--- a/src/web/config_load.cc |
| 140 | ++++ b/src/web/config_load.cc |
| 141 | +@@ -46,8 +46,10 @@ |
| 142 | + #include "context.h" |
| 143 | + #include "database/database.h" |
| 144 | + #include "database/db_param.h" |
| 145 | ++#include "util/tools.h" |
| 146 | + #include "util/xml_to_json.h" |
| 147 | + |
| 148 | ++#include <fmt/base.h> |
| 149 | + #include <fmt/chrono.h> |
| 150 | + #include <numeric> |
| 151 | + |
| 152 | +@@ -118,7 +120,6 @@ void Web::ConfigLoad::createItem(pugi::x |
| 153 | + template <typename T> |
| 154 | + void Web::ConfigLoad::setValue(pugi::xml_node& item, const T& value) |
| 155 | + { |
| 156 | +- static_assert(fmt::has_formatter<T, fmt::format_context>::value, "T must be formattable"); |
| 157 | + item.append_attribute(CONFIG_LOAD_VALUE) = fmt::to_string(value).c_str(); |
| 158 | + } |
| 159 | + |
| 160 | +@@ -920,7 +921,7 @@ void Web::ConfigLoad::writeAutoscan(pugi |
| 161 | + // Last modified |
| 162 | + item = values.append_child(CONFIG_LOAD_ITEM); |
| 163 | + createItem(item, ascs->getItemPath(indexList, { ConfigVal::A_AUTOSCAN_DIRECTORY_LMT }), ascs->option, ConfigVal::A_AUTOSCAN_DIRECTORY_LMT); |
| 164 | +- setValue(item, fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(adir->getPreviousLMT().count()))); |
| 165 | ++ setValue(item, fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt_localtime(adir->getPreviousLMT().count()))); |
| 166 | + } |
| 167 | + // Allow creation of entry in blank config |
| 168 | + { |
| 169 | +--- a/src/web/edit_load.cc |
| 170 | ++++ b/src/web/edit_load.cc |
| 171 | +@@ -102,7 +102,7 @@ pugi::xml_node Web::EditLoad::writeCoreI |
| 172 | + |
| 173 | + if (obj->getMTime() > std::chrono::seconds::zero()) { |
| 174 | + auto lmtEl = item.append_child("last_modified"); |
| 175 | +- lmtEl.append_attribute("value") = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(obj->getMTime().count())).c_str(); |
| 176 | ++ lmtEl.append_attribute("value") = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt_localtime(obj->getMTime().count())).c_str(); |
| 177 | + lmtEl.append_attribute("editable") = false; |
| 178 | + } else { |
| 179 | + auto lmtEl = item.append_child("last_modified"); |
| 180 | +@@ -112,7 +112,7 @@ pugi::xml_node Web::EditLoad::writeCoreI |
| 181 | + |
| 182 | + if (obj->getUTime() > std::chrono::seconds::zero()) { |
| 183 | + auto lmtEl = item.append_child("last_updated"); |
| 184 | +- lmtEl.append_attribute("value") = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(obj->getUTime().count())).c_str(); |
| 185 | ++ lmtEl.append_attribute("value") = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt_localtime(obj->getUTime().count())).c_str(); |
| 186 | + lmtEl.append_attribute("editable") = false; |
| 187 | + } else { |
| 188 | + auto lmtEl = item.append_child("last_updated"); |
| 189 | +@@ -252,7 +252,7 @@ void Web::EditLoad::writeItemInfo(const |
| 190 | + |
| 191 | + metaEntry = metaData.append_child("metadata"); |
| 192 | + metaEntry.append_attribute("metaname") = fmt::format("upnp:lastPlaybackTime@group[{}]", playStatus->getGroup()).c_str(); |
| 193 | +- metaEntry.append_attribute("metavalue") = fmt::format("{:%Y-%m-%d T %H:%M:%S}", fmt::localtime(playStatus->getLastPlayed().count())).c_str(); |
| 194 | ++ metaEntry.append_attribute("metavalue") = fmt::format("{:%Y-%m-%d T %H:%M:%S}", fmt_localtime(playStatus->getLastPlayed().count())).c_str(); |
| 195 | + metaEntry.append_attribute("editable") = false; |
| 196 | + |
| 197 | + if (playStatus->getLastPlayedPosition() > std::chrono::seconds::zero()) { |
0 commit comments