A user, barryvan, noticed that the anniversaries page on their forum is showing dates one day in the past. They suspect this might be due to their time zone (GMT+8) differing from the server’s time zone. Others agree that this is an issue, particularly for localized communities.
jomaxro points out that Discourse already localizes times elsewhere in the UI, so this inconsistency feels like a bug. pfaffman wonders if fixing this issue would require accounting for 24+ different time zones.
A possible solution is to display anniversaries based on the user’s local time zone, as suggested by sam. techAPJ mentions that a fix has been implemented to consider time zone offsets.
However, techAPJ later notes that some edge cases remain, particularly for users who created their accounts between 23:30 and 00:00. These issues have been addressed through subsequent commits.
The discussion highlights the need for a more nuanced approach to handling time zones in Discourse, especially for localized communities.
That’s one way to look at it I guess. But I’m assuming the users are queried on page load, so there’s really only “one” set at a time.
Here’s a better example. The post you just made shows up for me as “June 8, 2017 12:45 AM”. If I was to fly across the country to California, I’d expect that post to show as “June 7, 2017 9:45 PM”.
…and I just earned the “anniversary” badge this morning. This does feel like a bug to me.
Could it be mitigated by simply changing the timezone of the server to something more applicable for my community? We’re (mainly) in Australia, so processing everything as, say, GMT+8 or GMT+10 would make this all feel less odd.
Since the server doesn’t know a user’s time zone, maybe the easiest fix for this would be to award the badge one day later? For some, that will mean they get it late, but that will probably not be experienced as a bug as much as an early award is.
Another option might be to simply specify in the UI that these times are based on the server’s time zone.
Я считаю, что в контексте сильно локализованного сообщества вы должны иметь возможность указывать часовой пояс для «дня торта» (cakeday) в Discourse. Изменение часового пояса сервера — это не то, что мы можем сделать.
Это сложная задача, и я не уверен, как её решить, даже теперь, когда мы разрешили пользователям указывать «часовые пояса».
Если вы зарегистрировались на форуме в Австралии 2 января 2019 года в 8:00.
Ваша годовщина (согласно «дню торта») будет 1 января 2010 года.
Когда вы посетите страницу годовщин в 8:00 2 января, вы увидите годовщины от 1 января 2010 года, а не 2-го числа.
Кажется, здесь речь идёт о том, чтобы использовать «локальные» часовые пояса, определённые в профилях пользователей, для учёта подобных ситуаций.
То есть:
Ваша годовщина должна быть 1 января 2019 года, так как ваш локальный часовой пояс в профиле пользователя — Австралия.
Когда вы посетите страницу годовщин 2-го числа, вы должны видеть 2-е число.
На данный момент я поддерживаю простое решение: при отображении страницы годовщин учитывать локальный часовой пояс текущего пользователя и использовать эту дату вместо даты UTC «сейчас» для случаев, когда пользователь авторизован. Это должно быть довольно простое изменение, возможно, всего пара строк кода.
Я полагаю, что @tgxworld уже исправил это, чтобы учитывать смещение часового пояса, через:
и
РЕДАКТИРОВАНИЕ: Я нахожусь в часовом поясе UTC+5:30, но у меня смещение составляет 6 часов, поэтому я наблюдаю несколько пограничных случаев для пользователей, создавших аккаунт между 23:30 и 00:00. Изучаю это.