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

Update fromNow plugin #189

Merged
merged 13 commits into from
May 25, 2018
Merged

Update fromNow plugin #189

merged 13 commits into from
May 25, 2018

Conversation

iamkun
Copy link
Owner

@iamkun iamkun commented May 22, 2018

@aalises

I update the code of fromNow plugin a little bit. Here is the reason:

In previous code, we use resabs !== P[i].v to check if it is singular a month or 2 months.

However, there is some disadvantage of this kind of check, it must be exactly the same time in millisecond, otherwise, it will result 1 month instead of a month

So my solution is, still implement it in Moment.js's way.

We set the output to a range of time. Check the table blew:

Range Key Sample Output
0 to 44 seconds s a few seconds ago
44 to 44 seconds ss 44 seconds ago
45 to 89 seconds min a minute ago
90 seconds to 44 minutes mins 2 minutes ago ... 44 minutes ago
45 to 89 minutes h an hour ago
90 minutes to 21 hours hh 2 hours ago ... 21 hours ago
22 to 35 hours d a day ago
36 hours to 25 days dd 2 days ago ... 25 days ago
26 to 45 days M a month ago
46 days to 10 months MM 2 months ago ... 10 months ago
11 months to 17months y a year ago
18months+ yy 2 years ago ... 20 years ago

Also, added from to toNow APIs.

Should we come up a new name for this plugin, since it's not only fromNow now

@codecov-io
Copy link

codecov-io commented May 22, 2018

Codecov Report

Merging #189 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #189   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          15     15           
  Lines         297    308   +11     
  Branches       50     52    +2     
=====================================
+ Hits          297    308   +11
Impacted Files Coverage Δ
src/locale/es.js 100% <ø> (ø) ⬆️
src/plugin/fromNow.js 100% <100%> (ø) ⬆️

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 de7164a...74f8af2. Read the comment docs.

@iamkun iamkun added the discussion Further discussion label May 23, 2018
@aalises
Copy link
Contributor

aalises commented May 23, 2018

Hi! Thank you very much for your work! It indeed is better that way. When I designed the plugin I had timeago.js in mind and a very basic approach to it, not as complex as moment.js

@iamkun
Copy link
Owner Author

iamkun commented May 23, 2018

Thanks @aalises.

Any review here?

@iamkun iamkun merged commit dfd8f40 into master May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants