message: add utc-offset field

Add a new db field for storing UTC-offset for the Date: field.
This commit is contained in:
Dirk-Jan C. Binnema
2026-07-27 20:55:52 +03:00
committed by Seth Ladygo
parent 501d27ad89
commit 0bea84adce
5 changed files with 38 additions and 10 deletions

View File

@ -334,13 +334,17 @@ MimeMessage::make_from_text(const std::string& text)
return make_from_stream(std::move(stream));
}
Option<int64_t>
Option<MimeMessage::Date>
MimeMessage::date() const noexcept
{
if (/*const*/GDateTime *dt{g_mime_message_get_date(self())}; !dt)
return Nothing;
else
return g_date_time_to_unix(dt);
else {
constexpr auto usecs_per_sec = 1'000'000;
return Date{ g_date_time_to_unix(dt),
g_date_time_get_utc_offset(dt) / usecs_per_sec };
}
}
constexpr Option<GMimeAddressType>
@ -431,7 +435,8 @@ MimeMessage::contacts(Contact::Type ctype) const noexcept
return {};
Contacts contacts;
add_contacts(addrs, ctype, date().value_or(0), contacts);
const auto mdate{date()};
add_contacts(addrs, ctype, mdate ? mdate->first : 0, contacts);
return contacts;
}