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.
Creo que, en el contexto de una comunidad muy localizada, se debería permitir especificar la zona horaria para el «cakeday» de Discourse. Cambiar la zona horaria del servidor no es algo que podamos hacer realmente.
Esto es un asunto complicado y no estoy seguro de cómo resolverlo, incluso ahora que permitimos que los usuarios especifiquen «zonas horarias».
Si te registraste en un foro en Australia el 2 de enero de 2019 a las 8:00 a. m.:
Tu primer aniversario según el «cakeday» será el 1 de enero de 2020.
Cuando visites la página de aniversarios a las 8:00 a. m. del 2 de enero, verás aniversarios del 1 de enero de 2020 en lugar del 2.
Supongo que lo que estamos pidiendo aquí es que se utilicen las zonas horarias «locales» definidas en los perfiles de los usuarios para tener esto en cuenta.
Es decir:
Tu primer aniversario debería ser el 1 de enero de 2020 porque tu zona horaria local en tu perfil de usuario es Australia.
Cuando visites la página de aniversarios el 2, deberías ver el 2.
Por ahora, creo que apoyo la solución trivial, que consiste en que, al renderizar la página de aniversarios, se consulte la zona horaria local del usuario actual y se utilice esa fecha en lugar de la fecha UTC actual, para los casos en los que un usuario ha iniciado sesión. Debería ser un cambio bastante sencillo, quizás de dos líneas de código.
Creo que @tgxworld ya solucionó esto para tener en cuenta la diferencia horaria mediante:
y
EDITO: Estoy en la zona horaria UTC+5:30, pero tengo un desfase de 6 horas, por lo que estoy observando algunos casos límite para usuarios que crearon su cuenta entre las 23:30 y las 00:00. Estoy investigándolo.