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

Allow to select 24h time format #28371

Closed
ensc opened this issue Dec 6, 2023 · 14 comments · Fixed by #29651
Closed

Allow to select 24h time format #28371

ensc opened this issue Dec 6, 2023 · 14 comments · Fixed by #29651
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@ensc
Copy link

ensc commented Dec 6, 2023

Feature Description

gitea seems already to support the 24h time format but it appears that this is bound to the language settings.

Please add either

  • an option to select the time format explicitly, or
  • add more language variants (e.g. "english(uk)" -> 24h, "english(colonies)" -> 12h)

Time format and interface language are usually two different things. E.g. I prefer english language for technical content but 12h time format is completely unreadable for me.

Screenshots

No response

@ensc ensc added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Dec 6, 2023
@silverwind
Copy link
Member

You mean the dates displayed on the web interface? We are using https://github.com/github/relative-time-element#relative-time-element and it does not seem to have an option for 24h format, so likely it would need to be contributed there first.

@ensc
Copy link
Author

ensc commented Dec 13, 2023

@silverwind Problem is

<html lang="en-US" class="theme-auto">

When this would be lang="en-GB", then the 24h time format will be used. Having an additional "English (GB)" language option would probably the easiest solution.

@silverwind
Copy link
Member

silverwind commented Dec 13, 2023

Hmm maybe a "en-GB" locale could be added as an alias to "en-US". I don't see us maintaining separate translations for it, too little gain.

@inferenceus
Copy link

inferenceus commented Mar 1, 2024

I completely agree that 24-hour time format should be available. It's especially important in technical environments where correctness is required. I'd go further and say ISO 8601 (YYYY-MM-DD hh:mm:ss) should be available as the entire date and time string, regardless of UI language, which seems available in some conditions in the web UI I haven't been able to pin down yet.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Mar 2, 2024

I think there is a start for supporting this: Add global setting how timestamps should be rendered #28657

;;
;; The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`.
;; `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago).
;PREFERRED_TIMESTAMP_TENSE = mixed

More improvements could be done based on that approach (if there could be found more).

ps: it is only a instance-wide config, not a user-level config .....

@inferenceus
Copy link

@wxiaoguang

I think there is a start for supporting this: Add global setting how timestamps should be rendered #28657

;;
;; The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`.
;; `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago).
;PREFERRED_TIMESTAMP_TENSE = mixed

More improvements could be done based on that approach (if there could be found more).

I agree with this. It looks like a great way to implement it.

ps: it is only a instance-wide config, not a user-level config .....

That's fine by me. I'd do it server-wide, anyway.

@silverwind
Copy link
Member

silverwind commented Mar 7, 2024

I don't like a instance-wide setting, it forces the admin's preference onto users, it's disrespectful to users. There are way to detect 24h preference in JS. Also <relative-time> docs says:

Dates are displayed before months, and a 24-hour clock is used, according to the user's browser settings.

So maybe it's already supported and you just need to fix your OS/browser locale settings?

@silverwind
Copy link
Member

I checked locally and it seems it's not working for me. OS has 24h format:

image

Gitea displays 12h:

image

@denyskon
Copy link
Member

denyskon commented Mar 7, 2024

image
Works for me

@denyskon
Copy link
Member

denyskon commented Mar 7, 2024

Oh it really depends on your Gitea language, with English I also get 12h format

@silverwind
Copy link
Member

I found the fix, PR incoming...

@silverwind
Copy link
Member

#29651

lunny pushed a commit that referenced this issue Mar 8, 2024
Fixes: #28371

Fixed by using a JS solution that formats according to `lang`, but alters the 24h format setting as per user's locale. This will work for all tooltips:

<img width="243" alt="Screenshot 2024-03-07 at 23 03 35" src="https://github.com/go-gitea/gitea/assets/115237/6d16c71c-6786-4eda-8cdc-50ec68ba62c6">
<img width="250" alt="Screenshot 2024-03-07 at 23 03 17" src="https://github.com/go-gitea/gitea/assets/115237/4e26bbb7-12df-4b81-bd37-14705e87e8f7">
<img width="310" alt="Screenshot 2024-03-07 at 23 14 34" src="https://github.com/go-gitea/gitea/assets/115237/1ef599f0-6401-4e19-b1da-59cdfc09b0f6">

I think there is only one other place in the UI where we render such absolute dates, which is in the actions view and which I've also fixed:

<img width="275" alt="Screenshot 2024-03-07 at 23 04 00" src="https://github.com/go-gitea/gitea/assets/115237/df0fbe1f-96ee-4338-ab5e-2b10e215005d">
@inferenceus
Copy link

inferenceus commented Mar 8, 2024

@silverwind

I don't like a instance-wide setting, it forces the admin's preference onto users, it's disrespectful to users.

Some people like instance-wide enforcement, and there are good reasons for it, such as standards compliance which is very important, such as ISO 8601 in this case. It's still a choice, either way. We currently don't have a choice at all. Well, at least until #29651 .

@silverwind
Copy link
Member

Locale settings can be forced to users if you control their browser or OS and that will work for many websites not just gitea.

DennisRasey pushed a commit to DennisRasey/forgejo that referenced this issue Mar 13, 2024
Fixes: go-gitea/gitea#28371

Fixed by using a JS solution that formats according to `lang`, but alters the 24h format setting as per user's locale. This will work for all tooltips:

<img width="243" alt="Screenshot 2024-03-07 at 23 03 35" src="https://github.com/go-gitea/gitea/assets/115237/6d16c71c-6786-4eda-8cdc-50ec68ba62c6">
<img width="250" alt="Screenshot 2024-03-07 at 23 03 17" src="https://github.com/go-gitea/gitea/assets/115237/4e26bbb7-12df-4b81-bd37-14705e87e8f7">
<img width="310" alt="Screenshot 2024-03-07 at 23 14 34" src="https://github.com/go-gitea/gitea/assets/115237/1ef599f0-6401-4e19-b1da-59cdfc09b0f6">

I think there is only one other place in the UI where we render such absolute dates, which is in the actions view and which I've also fixed:

<img width="275" alt="Screenshot 2024-03-07 at 23 04 00" src="https://github.com/go-gitea/gitea/assets/115237/df0fbe1f-96ee-4338-ab5e-2b10e215005d">

(cherry picked from commit f86e9a03673b70d660a4b7a1e53748757d7a45fa)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants