Wrong custom date and time in silenced and suspended warnings

AI-generated summary

Wrong custom date and time in silenced and suspended warnings

A bug was reported by Don where the suspend and silenced warnings and emails contain the wrong date and time. The issue occurs when setting a custom date and time on the suspend modal. The email shows an incorrect date and time, while the user card and admin page show a different, also incorrect, date and time.

JammyDodger investigated and found discrepancies between the input and displayed times/dates, including the email being an hour off and any suspension longer than a day rounding out the time to midnight and knocking a day off the date.

andrei was able to reproduce the problems and created a pull request to fix the date in emails for silencing and suspending users, converting dates to the user’s timezone. andrei also reported that the rounding bug was fixed by joffreyjaffeux.

Hello,

I noticed the suspend and silenced warnings and emails contains wrong date. Sorry if I missed something about this.

Repro

  1. Set up a (custom date and time) on suspend modal. I seted up a week suspend.
  2. Set a reason and a custom email message
  3. Click the suspend button

In the email it says until May 12, 2022 at 22:00

On the user card it shows until May 13, 2022 at 00:00


Same on admin page.
Screenshot 2022-05-06 at 10.13.22

I think on the user card and admin the time should be 9:32 and in the email the date and time both wrong.

Thanks :slightly_smiling_face:

3 Likes

I’ve been having a little play with this and there does seem to be some discrepancy between times/dates input and time/dates displayed.

For a suspension of 1 day (the pre-entered default):





And for a custom suspension of 1 week:




In both cases the email was an hour off, and any suspension longer than a day rounded out the time to midnight, and also knocked a day off the date in the email version.

Edit: Making sure I got all the right screenshots along the way clouded my thinking. :slightly_smiling_face:

It’s because it’s knocking an hour off 00:00 which causes it to be a day early. So, it’s more about the lost hour between input and email. And @Don lost two. :thinking:

3 Likes

I can reproduce all problems. I’ll take a look at it.

3 Likes

This fixes date in emails both when silencing and suspending users. Dates will be converted to user’s timezone:

https://github.com/discourse/discourse/pull/16918

Next we need to fix the rounding issue. I am looking at that.

3 Likes

The rounding bug was just fixed by @j.jaffeux in

https://github.com/discourse/discourse/pull/16937

3 Likes

This topic was automatically closed after 3 days. New replies are no longer allowed.