From 9eb50432aabf0e09f3db66294564ec91fac2c94d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 6 Jan 2025 20:00:59 +0100 Subject: Fix email date format in non-English locales (#2928). --- src/lib/email.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lib/email.cc') diff --git a/src/lib/email.cc b/src/lib/email.cc index 2da57e257..a731501bc 100644 --- a/src/lib/email.cc +++ b/src/lib/email.cc @@ -24,6 +24,7 @@ #include "email.h" #include "exceptions.h" #include "variant.h" +#include #include #include #include @@ -113,7 +114,11 @@ void Email::create(time_t time) { char date_buffer[128]; - strftime(date_buffer, sizeof(date_buffer), "%a, %d %b %Y %H:%M:%S ", localtime(&time)); + + auto english_locale = newlocale(LC_TIME_MASK, "C", 0); + DCPOMATIC_ASSERT(english_locale); + dcp::ScopeGuard sg = [english_locale]() { freelocale(english_locale); }; + strftime_l(date_buffer, sizeof(date_buffer), "%a, %d %b %Y %H:%M:%S ", localtime(&time), english_locale); auto const utc_time = boost::posix_time::second_clock::universal_time(); auto const local_time = boost::date_time::c_local_adjustor::utc_to_local(utc_time); -- cgit v1.2.3