diff --git a/lib/index/mu-indexer.cc b/lib/index/mu-indexer.cc index 3bf72109..e7019c3a 100644 --- a/lib/index/mu-indexer.cc +++ b/lib/index/mu-indexer.cc @@ -1,5 +1,5 @@ /* -** Copyright (C) 2020-2022 Dirk-Jan C. Binnema +** Copyright (C) 2020-2023 Dirk-Jan C. Binnema ** ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the @@ -115,7 +115,7 @@ struct Indexer::Private { Scanner scanner_; const size_t max_message_size_; - time_t dirstamp_{}; + ::time_t dirstamp_{}; std::size_t max_workers_; std::vector workers_; std::thread scanner_worker_; @@ -161,9 +161,8 @@ Indexer::Private::handler(const std::string& fullpath, struct stat* statbuf, dirstamp_ = store_.dirstamp(fullpath); if (conf_.lazy_check && dirstamp_ >= statbuf->st_ctime && htype == Scanner::HandleType::EnterNewCur) { - mu_debug("skip {} (seems up-to-date: {} >= {})", fullpath, - time_to_string("%FT%T", dirstamp_), - time_to_string("%FT%T", statbuf->st_ctime)); + mu_debug("skip {} (seems up-to-date: {:%FT%T} >= {:%FT%T})", + fullpath, mu_time(dirstamp_), mu_time(statbuf->st_ctime)); return false; } @@ -461,7 +460,7 @@ Indexer::progress() const return priv_->progress_; } -time_t +::time_t Indexer::completed() const { return priv_->completed_; diff --git a/lib/index/mu-indexer.hh b/lib/index/mu-indexer.hh index 0c678a6a..da7dad09 100644 --- a/lib/index/mu-indexer.hh +++ b/lib/index/mu-indexer.hh @@ -115,7 +115,7 @@ public: * * @return the time or 0 */ - time_t completed() const; + ::time_t completed() const; private: struct Private; diff --git a/lib/mu-server.cc b/lib/mu-server.cc index 412fda2b..ff322e83 100644 --- a/lib/mu-server.cc +++ b/lib/mu-server.cc @@ -532,12 +532,11 @@ Server::Private::contacts_handler(const Command& cmd) const auto tstampstr = cmd.string_arg(":tstamp").value_or(""); const auto maxnum = cmd.number_arg(":maxnum").value_or(0 /*unlimited*/); - const auto after{afterstr.empty() ? 0 : - parse_date_time(afterstr, true).value_or(0)}; + const auto after{afterstr.empty() ? 0 : parse_date_time(afterstr, true).value_or(0)}; const auto tstamp = g_ascii_strtoll(tstampstr.c_str(), NULL, 10); - mu_debug("find {} contacts last seen >= {} (tstamp: {})", - personal ? "personal" : "any", time_to_string("%c", after), tstamp); + mu_debug("find {} contacts last seen >= {:%c} (tstamp: {})", + personal ? "personal" : "any", mu_time(after), tstamp); auto match_contact = [&](const Contact& ci)->bool { if (tstamp > ci.tstamp) diff --git a/mu/mu-cmd-cfind.cc b/mu/mu-cmd-cfind.cc index 86c818b1..044458fd 100644 --- a/mu/mu-cmd-cfind.cc +++ b/mu/mu-cmd-cfind.cc @@ -171,12 +171,12 @@ output_bbdb(ItemType itype, OptContact contact, const Options& opts) return; const auto names{guess_first_last_name(contact->name)}; - const auto now{time_to_string("%Y-%m-%d", ::time(NULL))}; - const auto timestamp{time_to_string("%Y-%m-%d", contact->message_date)}; + const auto now{mu_format("{:%Y-%m-%d}", mu_time(::time({})))}; + const auto timestamp{mu_format("{:%Y-%m-%d}", mu_time(contact->message_date))}; mu_println("[\"{}\" \"{}\" nil nil nil nil (\"{}\") " - "((creation-date . \"{}\") (time-stamp . \"{}\")) nil]", - names.first, names.second, contact->email, now, timestamp); + "((creation-date . \"{}\") (time-stamp . \"{}\")) nil]", + names.first, names.second, contact->email, now, timestamp); } static void @@ -212,7 +212,7 @@ output_json(ItemType itype, OptContact contact, const Options& opts) name, Mu::quote(contact->display_name()), contact->message_date, - time_to_string("%FT%TZ", contact->message_date, true/*utc*/), + mu_format("{:%FT%TZ}", mu_time(contact->message_date, true/*utc*/)), contact->personal ? "true" : "false", contact->frequency); mu_print(" }}"); diff --git a/mu/mu-cmd-find.cc b/mu/mu-cmd-find.cc index 55d4baa9..ec5a9283 100644 --- a/mu/mu-cmd-find.cc +++ b/mu/mu-cmd-find.cc @@ -234,8 +234,8 @@ display_field(const Message& msg, Field::Id field_id) } else /* as string */ return msg.document().string_value(field_id); case Field::Type::TimeT: - return time_to_string( - "%c", static_cast<::time_t>(msg.document().integer_value(field_id))); + return mu_format("{:%c}", + mu_time(msg.document().integer_value(field_id))); case Field::Type::ByteSize: return to_string(msg.document().integer_value(field_id)); case Field::Type::StringList: diff --git a/mu/mu-cmd-info.cc b/mu/mu-cmd-info.cc index f93f80f0..dd0f133a 100644 --- a/mu/mu-cmd-info.cc +++ b/mu/mu-cmd-info.cc @@ -182,7 +182,7 @@ topic_store(const Mu::Store& store, const Options& opts) if (t == 0) return "never"; else - return time_to_string("%c", t); + return mu_format("{:%c}", mu_time(t)); }; Table info; diff --git a/mu/mu-cmd-verify.cc b/mu/mu-cmd-verify.cc index 163e0d88..62edeeca 100644 --- a/mu/mu-cmd-verify.cc +++ b/mu/mu-cmd-verify.cc @@ -46,12 +46,12 @@ print_signature(const Mu::MimeSignature& sig, const Options& opts) const auto created{sig.created()}; key_val(col, "created", - created == 0 ? "unknown" : - time_to_string("%c", sig.created()).c_str()); + created == 0 ? std::string{"unknown"} : + mu_format("{:%c}", mu_time(sig.created()))); const auto expires{sig.expires()}; - key_val(col, "expires", expires==0 ? "never" : - time_to_string("%c", sig.expires()).c_str()); + key_val(col, "expires", expires==0 ? std::string{"never"} : + mu_format("{:%c}", mu_time(sig.expires()))); const auto cert{sig.certificate()}; key_val(col, "public-key algo", diff --git a/mu/mu-cmd-view.cc b/mu/mu-cmd-view.cc index a188ce9d..69589857 100644 --- a/mu/mu-cmd-view.cc +++ b/mu/mu-cmd-view.cc @@ -140,7 +140,7 @@ view_msg_plain(const Message& message, const Options& opts) print_field("Subject", message.subject(), color); if (auto&& date = message.date(); date != 0) - print_field("Date", time_to_string("%c", date), color); + print_field("Date", mu_format("{:%c}", mu_time(date)), color); print_field("Tags", join(message.tags(), ", "), color);