Fix message banner to not appear immediately after dismissal
The redisplay format "Aug 29, 2023, 12:00:00 AM" is not
supported by the document.cookie expires field [1], where it was
ignoring AM and PM. The expires field expects a GMT format such as
"Wed, 14 Jun 2017 07:00:00 GMT". Even though we fix this issue by
making the REST API send the right format, we have another issue
with timezones.
Let's say client is in IST timezone and current GMT time is
"27 Aug 2023 23:30:00" and equivalent IST is "28 Aug 2023 05:00:00".
So the redisplay from the REST API is "28 Aug 2023 00:00:00", which
translates to "28 Aug 2023 05:30:00" in IST. Which means the user will
see the message banner in next 30mins after its dismissal. Ideally the
banner must be redisplayed next day of the client, i.e.
"29 Aug 2023 00:00:00".
It is not the best approach to determine the redisplay time for banner
on server side, as the API has no clue about the client's next day.
Rather calculate the next day for redisplay on client itself, which
sets the correct time for redisplay.
[1] https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#write_a_new_cookie
Change-Id: Ic24b758a6f0d807c0fa6a2ed3f9bda125fa31c60
5 files changed