-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Thanks to such a good plug-in, Adapted to Asian semantic functional requirements #35
Comments
threshold
?
Hey @y377, thanks for trying this gem! The algorithm is defined in this method: jekyll-timeago/lib/jekyll-timeago/core.rb Line 64 in f6c7f1a
You can adjust it a bit using the |
Thanks for your reply, I was a little hasty, because I am a ruby novice, I tried for half a day, but it still failed to work, can you create an addition? def build_time_ago_slots(days_passed, depth, threshold, current_slots = [])
return current_slots if depth == 0 || days_passed == 0
range = days_to_range(days_passed)
days = days_in(range)
num_elems = (days_passed / days).to_i
current_slots << t(range, count: num_elems)
pending_days = days_passed - (num_elems * days)
custom_days = days_passed + (num_elems * days)
if pending_days > (days_passed * threshold).floor
build_time_ago_slots(pending_days, depth - 1, threshold, current_slots)
elsif
build_time_ago_slots(custom_days, depth, threshold, current_slots)
else
current_slots
end
end What I'm looking for is a judgment:
If the user enters a date of 7 days, he gets 1 week. If the user enters a date of 8 days, he gets 8 days. Because I am a Chinese user, for Chinese users, 1 week and 1 day ago, Chinese users are not used to such semantics, they prefer to get 8 days ago I don't know ruby,example demo:custom_days = 7 + ( week / 2 ) = 10.5 #(week / 2) =3.5;
if days < custom_days # The user entered 10 days;
return 10 days ago;
else # The user entered 11 days;
return 2 weeks ago; The same principle applies to months and years,What do I need to do? thank you!
Let me give you a logical thought (since I don't know ruby, I can only offer my humble opinion) : If this function is implemented, resulting in code refactoring, if the European and American users do not adapt to or do not need such semantics, is it possible to judge according to |
Thanks for such detailed explanation @y377! Not sure if I get your points though... The if condition
code
elsif condition
code
else
code
end Are you suggesting to introduce a new parameter Maybe you can check out the original pull request where the Let me know how it goes! |
@markets The expected effect is: if it is 3 days a week, I want to display 10 days; if it is 4 days a week, I want to display 2 weeks, what should I do? |
If I understood properly, you want something like:
To be honest, I'm not sure if this is actually possible with this gem, you should try with |
@y377 Was looking at this and thinking of ways to incorporate this, either here or in a separate gem. Can you help understand:
|
@captn3m0 Hi, I'm glad you're interested in this date. |
As mentioned above, how can I calculate it?
my
_config.yml
thanks!!
The text was updated successfully, but these errors were encountered: