Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display dates in local time #142

Open
cco3 opened this issue Apr 8, 2021 · 9 comments
Open

Display dates in local time #142

cco3 opened this issue Apr 8, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@cco3
Copy link

cco3 commented Apr 8, 2021

The Web UI currently displays thing like the "Created time", etc. using UTC time, but it might make sense to use local time or both UTC and local time.

(I was having trouble figuring out which scan I was looking at..."was this the one I started at 8:00 or at 11:00?")

@tdruez tdruez added this to the 2021-05 milestone Apr 26, 2021
tdruez added a commit that referenced this issue Apr 27, 2021
Signed-off-by: Thomas Druez <tdruez@nexb.com>
@tdruez
Copy link
Member

tdruez commented Apr 28, 2021

@cco3 Summary of changes about "dates" in latest version:

  • The local installation timezone can now be configured using the TIME_ZONE settings. See https://scancodeio.readthedocs.io/en/latest/scancodeio-settings.html#time-zone for details.
  • The current timezone is now displayed along the date in the web UI.
  • The creation date of a project is displayed as a more readable "Created 6 hours ago", the full date information can be displayed hovering the date label:
    date

@tdruez tdruez closed this as completed Apr 28, 2021
AyanSinhaMahapatra added a commit to AyanSinhaMahapatra/scancode.io that referenced this issue Apr 29, 2021
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
@cco3
Copy link
Author

cco3 commented Apr 30, 2021

By "The current timezone", do you mean the timezone specified in the settings? Why not just let the client display the time according to the local timezone?

@tdruez tdruez reopened this Apr 30, 2021
@tdruez
Copy link
Member

tdruez commented May 6, 2021

@cco3

By "The current timezone", do you mean the timezone specified in the settings?

Yes, Django allows to specify the timezone of the server, not to get the timezone for each clients. The dates are always stored as UTC in the database and displayed using the server defined timezone (TIME_ZONE settings).

Why not just let the client display the time according to the local timezone?

If by "local timezone" you mean "client timezone" rather than "server timezone", how would you get that information from the client?

@cco3
Copy link
Author

cco3 commented May 6, 2021

The server serves up UTC. The client then displays it according to the local timezone (i.e., using javascript). new Date(utcTimestamp).toString() would be one example that works in chrome.

Unfortunately the standard javascript time functions are very inconsistent across browsers, but there are libraries commonly used to fix that.

AyanSinhaMahapatra added a commit to AyanSinhaMahapatra/scancode.io that referenced this issue May 10, 2021
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
tdruez pushed a commit that referenced this issue May 11, 2021
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
@tdruez tdruez removed this from the 2021-05 milestone Jun 10, 2021
@cco3
Copy link
Author

cco3 commented Aug 6, 2021

Times are still being shown in UTC:

Screenshot from 2021-08-06 11-32-21

@pombredanne pombredanne added the enhancement New feature or request label Apr 15, 2022
@lf32
Copy link

lf32 commented Apr 15, 2022

v30.2.0

It works on setting the value for the TIME_ZONE variable in the env

time_env_zone

when variable value is set to IST

time_ist

when variable has no value set it's UTC

time_utc

@lf32
Copy link

lf32 commented Apr 15, 2022

why geo when value can be set directly in the settings?

@pombredanne
Copy link
Member

@lf32 Thank you for the excellent research!
Note that's changing the date system-wide including in the DB... which may not always be what one wants and may be keeping UTC there is simpler... The alternative is only to display a "local time" based on a web user date
The trick is to get the user date/time setting which is not something Django handles and is typically best done clien-side with JS afaik. See for instance https://github.com/adamcharnock/django-tz-detect

See also https://docs.djangoproject.com/en/4.0/topics/i18n/timezones/#template-tags

@cco3 Would be changing the setting be enough for you?

@lf32
Copy link

lf32 commented Apr 15, 2022

@pombredanne Thank you, I'll check them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants