BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
14.86k stars 1.87k forks source link

Datetime and TZ inconsistencies #4786

Open NekoiNemo opened 8 months ago

NekoiNemo commented 8 months ago

Attempted Debugging

Searched GitHub Issues

Describe the Scenario

I have the following issues and can't seem to figure out if this is a bug or a misconfiguration:

  1. When mousing over elements to get the exact dates - they are in UTC regardless of user's actual TZ. Now, they are correct (as in - this is the correct UTC time of the action), the "n units ago" is calculated correctly, they are stored in the database correctly, but the exact timestamp is shown in the UI without respect for user's TZ, and without indication that time is being displayed in UTC
  2. The way the exact timestamp is displayed is inconsistent:
    • For comments (as well as in Audit Log, User's last login and most other places) it displays good nice ISO timestamp: screenshot_1705673074
    • For books/pages it is displayed as such: screenshot_1705673002 screenshot_1705673070
    • And for Recent Activity column on the left - there's no popup with a timestamp at all

Exact BookStack Version

v23.12.1

Log Content

No response

Hosting Environment

Docker container (from LSIO) behind NGINX

  server:
    image: lscr.io/linuxserver/bookstack:latest
    environment:
      TZ: UTC
      APP_TIMEZONE: UTC
      APP_LANG: en
      APP_AUTO_LANG_PUBLIC: false

  db:
    image: lscr.io/linuxserver/mariadb:10.11.5
    environment:
      TZ: UTC

Host server is also in UTC (though it's locale isn't bound into containers)

ssddanbrown commented 8 months ago

Thanks for raising @NekoiNemo.

bug or a misconfiguration

Based upon what you've detailed, probably neither but instead a UX & consistency issue, and there's three things we should probably do:

The last point might be tricky, as I'm not sure we may specifically know the original timezone of a timestamp if the admin changes the configured timezone. I'd have to re-review how dates are stored and the interplay with timezone. Still might be better to just reflect the current configured timezone though since the otherwise worst case is maybe +/-24 hours of error, around the rare case someone changes their timezone.

bgartenmann commented 1 month ago

Hi @ssddanbrown I don't know how much you have looked into the timestamp/timezone issue already. We do have a rare/special case regarding this: We are operating two ships sailing around the world and have BookStack installed on both of them. They will travel through many different time zones within a year and we try to have our different systems reflect the current time zone they are in. I haven't found a way to dynamically set the time zone in BookStack running in a docker container. Other applications are using the "host" (container) time zone and for these I was able to mount the host time zone files into the docker container. Maybe something like this would be possible for the last point above as well?

ssddanbrown commented 1 month ago

@bgartenmann You could create a script to update the timezone value used for BookStack based on system timezone, but that won't fully solve the scenario since (from what I remember) the setting applies to both storage and display and is not intended to be changed frequently. There's various different options to address things there, but I'd consider that outside the scope of this specific issue (which is specifically focused on presentation).

bgartenmann commented 1 month ago

@ssddanbrown You are right that this is out of scope of this issue. Thanks for the tip with the script, I will look into that.