Skip to content

Conversation

@lunny
Copy link
Member

@lunny lunny commented Jan 3, 2021

This PR introduces rounding off numbers for time since.
i.e. Before, 1.6 year still displayed 1 year,
After 1.4 year will display 1 year, but 1.5 year will display 2 years.

Fix #4917

@lunny lunny added this to the 1.14.0 milestone Jan 3, 2021
@zeripath
Copy link
Contributor

zeripath commented Jan 3, 2021

I wonder if we might benefit from writing out what times we're aiming to display.

I'd also note that in British English we're likely to consider 18 months a half-way point between 1 year & 2 years. Not sure if it is the same in US English & International English though.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 3, 2021
@zeripath
Copy link
Contributor

zeripath commented Jan 3, 2021

might be worth taking a look at http://timeago.yarp.com/

@lunny
Copy link
Member Author

lunny commented Jan 4, 2021

A frontend solution may make i18n difficult.

@lafriks
Copy link
Member

lafriks commented Jan 4, 2021

unit tests fail

@zeripath
Copy link
Contributor

zeripath commented Jan 4, 2021

I wasn't suggesting using that library rather check/copy its algorithm

Copy link
Contributor

@bagasme bagasme left a comment

Choose a reason for hiding this comment

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

but what about the case for leap years?

@lunny lunny force-pushed the lunny/fix_round_display_since_time branch from 895e071 to 6761eab Compare January 27, 2021 04:12
@lunny lunny force-pushed the lunny/fix_round_display_since_time branch from 6761eab to 5d6b580 Compare January 27, 2021 15:35
@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 27, 2021
@lunny
Copy link
Member Author

lunny commented Jan 27, 2021

but what about the case for leap years?

Just ignored that. We just calculate the time distance.

@codecov-io
Copy link

Codecov Report

Merging #14226 (bf26bab) into master (41c0776) will increase coverage by 0.04%.
The diff coverage is 84.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14226      +/-   ##
==========================================
+ Coverage   42.09%   42.13%   +0.04%     
==========================================
  Files         758      758              
  Lines       81106    81181      +75     
==========================================
+ Hits        34139    34205      +66     
- Misses      41386    41391       +5     
- Partials     5581     5585       +4     
Impacted Files Coverage Δ
modules/timeutil/since.go 89.88% <84.41%> (-7.97%) ⬇️
modules/indexer/stats/db.go 56.00% <0.00%> (-12.00%) ⬇️
modules/log/event.go 59.90% <0.00%> (-1.89%) ⬇️
modules/git/repo_commit_nogogit.go 63.33% <0.00%> (-1.67%) ⬇️
services/pull/pull.go 42.64% <0.00%> (+0.49%) ⬆️
routers/api/v1/repo/pull.go 25.90% <0.00%> (+0.60%) ⬆️
models/repo_list.go 78.76% <0.00%> (+0.88%) ⬆️
models/unit.go 49.31% <0.00%> (+2.73%) ⬆️
modules/queue/manager.go 65.08% <0.00%> (+2.95%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c6e029...bf26bab. Read the comment docs.

@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 28, 2021
@6543 6543 merged commit 154b23d into go-gitea:master Jan 28, 2021
@lunny lunny deleted the lunny/fix_round_display_since_time branch January 28, 2021 13:08
@zeripath
Copy link
Contributor

zeripath commented Mar 1, 2021

Please send backport

zeripath pushed a commit to zeripath/gitea that referenced this pull request Mar 3, 2021
Backport go-gitea#14226

* Fix display since time round

* Fix since time

* Fix tests
@zeripath zeripath added the backport/done All backports for this PR have been created label Mar 3, 2021
zeripath added a commit that referenced this pull request Mar 3, 2021
Backport #14226

* Fix display since time round

* Fix since time

* Fix tests

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
@go-gitea go-gitea locked and limited conversation to collaborators Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wording in "last changed date"

7 participants