diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-06 20:46:33 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-06 20:46:35 +0100 |
| commit | cf50dd3ac0153935f6b4f1ae9da16bc2b473d1a0 (patch) | |
| tree | a4607f103db2a0a89b69d4c5f5045fc67a877ac0 /src/lib | |
| parent | f15d2872c717e97112f5b0becb4645b91d378cc6 (diff) | |
Pass a time into Email::create().
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/email.cc | 13 | ||||
| -rw-r--r-- | src/lib/email.h | 2 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/lib/email.cc b/src/lib/email.cc index b91ae4702..2da57e257 100644 --- a/src/lib/email.cc +++ b/src/lib/email.cc @@ -110,15 +110,14 @@ Email::get_data(void* ptr, size_t size, size_t nmemb) void -Email::create() +Email::create(time_t time) { char date_buffer[128]; - time_t now = time (0); - strftime (date_buffer, sizeof(date_buffer), "%a, %d %b %Y %H:%M:%S ", localtime(&now)); + strftime(date_buffer, sizeof(date_buffer), "%a, %d %b %Y %H:%M:%S ", localtime(&time)); - auto const utc_now = boost::posix_time::second_clock::universal_time (); - auto const local_now = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local (utc_now); - auto offset = local_now - utc_now; + auto const utc_time = boost::posix_time::second_clock::universal_time(); + auto const local_time = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(utc_time); + auto offset = local_time - utc_time; auto end = date_buffer + strlen(date_buffer); snprintf(end, sizeof(date_buffer) - (end - date_buffer), "%s%02d%02d", (offset.hours() >= 0 ? "+" : "-"), int(abs(offset.hours())), int(offset.minutes())); @@ -191,7 +190,7 @@ Email::create() void Email::send(string server, int port, EmailProtocol protocol, string user, string password) { - create(); + create(time(nullptr)); curl_global_init (CURL_GLOBAL_DEFAULT); diff --git a/src/lib/email.h b/src/lib/email.h index 878c5b131..24f20956a 100644 --- a/src/lib/email.h +++ b/src/lib/email.h @@ -54,7 +54,7 @@ private: std::string fix (std::string s) const; static std::string encode_rfc1342 (std::string subject); - void create(); + void create(time_t time); std::string _from; std::vector<std::string> _to; |
