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

Add global setting how timestamps should be rendered #28657

Merged
merged 7 commits into from
Jan 2, 2024

Conversation

yardenshoham
Copy link
Member

@yardenshoham yardenshoham commented Dec 30, 2023

Some admins prefer all timestamps to display the full date instead of relative time. They can do that now by setting

[ui]
PREFERRED_TIMESTAMP_TENSE = absolute

This setting is set to mixed by default, allowing dates to render as "5 hours ago". Here are some screenshots of the UI with this setting set to absolute:
image
image
image

Some admins prefer all timestamps to display the full date instead of relative time. They can do that now by setting

```ini
[ui]
PREFER_ABSOLUTE_TIMESTAMPS = true
```

Signed-off-by: Yarden Shoham <[email protected]>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 30, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 30, 2023
@yardenshoham yardenshoham added the type/enhancement An improvement of existing functionality label Dec 30, 2023
custom/conf/app.example.ini Outdated Show resolved Hide resolved
@@ -1244,6 +1244,9 @@ LEVEL = Info
;; Change the sort type of the explore pages.
;; Default is "recentupdate", but you also have "alphabetically", "reverselastlogin", "newest", "oldest".
;EXPLORE_PAGING_DEFAULT_SORT = recentupdate
;;
;; Whether to prefer all timestamps to be rendered as absolute. Setting this to false means some timestamps would render as relative.
;PREFER_ABSOLUTE_TIMESTAMPS = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a related note, wouldn't it be better to name the setting

Suggested change
;PREFER_ABSOLUTE_TIMESTAMPS = false
;TIMESTAMP_FORMAT = relative

with relative,absolute being the possible options (for now)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think other options exist

Copy link
Member

@delvh delvh Dec 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can think of a few at the top of my head: relative_v2, relative_legacy, absolute_v2, absolute_legacy, both, …

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If relative is set here, some timestamps still render as absolute though (e.g. joined on date in profile page)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but those are either intended or a bug.
Either way, to me it makes sense despite some minor exceptions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, if you add a comment why relative does not yet exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current description is:

  • PREFERRED_TIMESTAMP_TENSE: mixed: The tense all timestamps should be rendered as. Possible values are absolute time (i.e. 1970-01-01, 11:59) or mixed which means some timestamps would render as relative (i.e. 2 days ago).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today some of our timestamps are absolute and some are relative. I don't know why.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some most

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 0504a8c

@delvh delvh changed the title Add the option to prefer all timestamps to be absolute Add global setting how timestamps should be rendered Dec 30, 2023
yardenshoham and others added 2 commits December 30, 2023 12:28
Signed-off-by: Yarden Shoham <[email protected]>
Co-authored-by: delvh <[email protected]>
Signed-off-by: Yarden Shoham <[email protected]>
@JakobDev
Copy link
Contributor

Should we make this also a user setting?

@yardenshoham
Copy link
Member Author

Tried it in #24342

@delvh
Copy link
Member

delvh commented Dec 30, 2023

See #24342, but yes, this is probably the next step.

@wxiaoguang
Copy link
Contributor

Should we make this also a user setting?

The user setting system has some framework-level problems: too complex to use, and it might cause bugs easily.

I have refactored the system setting package in #27000 , IMO the user setting system also needs some big refactoring.

@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 31, 2023
@yardenshoham yardenshoham added type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed type/enhancement An improvement of existing functionality labels Dec 31, 2023
custom/conf/app.example.ini Outdated Show resolved Hide resolved
docs/content/administration/config-cheat-sheet.en-us.md Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 1, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 1, 2024
@delvh delvh added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 1, 2024
@delvh delvh added this to the 1.22.0 milestone Jan 1, 2024
@lunny lunny merged commit cdc33b2 into go-gitea:main Jan 2, 2024
25 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 2, 2024
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jan 2, 2024
* giteaofficial/main:
  Add global setting how timestamps should be rendered (go-gitea#28657)
  [skip ci] Updated translations via Crowdin
  Upgrade xorm to new version which supported update join for all supported databases (go-gitea#28590)
  Fix: system webhooks API bug (go-gitea#28531)
  Fix alpine package files are not rebuilt (go-gitea#28638)
  Fix migration test (go-gitea#28659)
  Avoid cycle-redirecting user/login page (go-gitea#28636)
  Fix long package version names overflowing (go-gitea#28619)
@yardenshoham yardenshoham deleted the prefer-absolute-timestamps branch January 2, 2024 08:25
fuxiaohei pushed a commit to fuxiaohei/gitea that referenced this pull request Jan 17, 2024
- Resolves go-gitea#22493
- Related to go-gitea#4520

Some admins prefer all timestamps to display the full date instead of
relative time. They can do that now by setting

```ini
[ui]
PREFERRED_TIMESTAMP_TENSE = absolute
```

This setting is set to `mixed` by default, allowing dates to render as
"5 hours ago". Here are some screenshots of the UI with this setting set
to `absolute`:

![image](https://github.com/go-gitea/gitea/assets/20454870/f496457f-6afa-44be-a1e7-249ee5fe0706)

![image](https://github.com/go-gitea/gitea/assets/20454870/c03b14f5-063d-4e13-9780-76ab002d76a9)

![image](https://github.com/go-gitea/gitea/assets/20454870/f4b34e28-1546-4374-9199-c43348844edd)

---------

Signed-off-by: Yarden Shoham <[email protected]>
Co-authored-by: delvh <[email protected]>
silverwind pushed a commit to silverwind/gitea that referenced this pull request Feb 20, 2024
- Resolves go-gitea#22493
- Related to go-gitea#4520

Some admins prefer all timestamps to display the full date instead of
relative time. They can do that now by setting

```ini
[ui]
PREFERRED_TIMESTAMP_TENSE = absolute
```

This setting is set to `mixed` by default, allowing dates to render as
"5 hours ago". Here are some screenshots of the UI with this setting set
to `absolute`:

![image](https://github.com/go-gitea/gitea/assets/20454870/f496457f-6afa-44be-a1e7-249ee5fe0706)

![image](https://github.com/go-gitea/gitea/assets/20454870/c03b14f5-063d-4e13-9780-76ab002d76a9)

![image](https://github.com/go-gitea/gitea/assets/20454870/f4b34e28-1546-4374-9199-c43348844edd)

---------

Signed-off-by: Yarden Shoham <[email protected]>
Co-authored-by: delvh <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/docs size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

viewing dates requires mouse hover
6 participants