1
0
mirror of https://github.com/anope/anope.git synced 2026-07-04 10:43:14 +02:00

Add support for users setting their local timezone.

This commit is contained in:
Sadie Powell
2025-10-05 18:55:33 +01:00
parent 1a5d49b7f6
commit 8b6c6fdd81
4 changed files with 257 additions and 1 deletions
+10 -1
View File
@@ -619,14 +619,23 @@ Anope::string Anope::Duration(time_t t, const NickCore *nc, bool round)
Anope::string Anope::strftime(time_t t, const NickCore *nc, bool short_output)
{
static ExtensibleRef<Anope::string> timezone("timezone");
if (nc)
{
Language::SetLocale(nc->language.c_str());
auto *tz = timezone ? timezone->Get(nc) : nullptr;
setenv("TZ", tz ? tz->c_str() : "UTC", 1);
tzset();
}
char buf[BUFSIZE];
strftime(buf, sizeof(buf), "%b %d %Y %H:%M:%S %Z", gmtime(&t));
strftime(buf, sizeof(buf), "%b %d %Y %H:%M:%S %Z", (nc ? localtime(&t) : gmtime(&t)));
if (nc)
{
unsetenv("TZ");
Language::ResetLocale();
}
if (short_output)
return buf;