lib/mu: use fmt-based time/date formatting
For a small speedup
This commit is contained in:
@ -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(" }}");
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user