markets / jekyll-timeago Goto Github PK
View Code? Open in Web Editor NEW⌛ Ruby library to compute distance of dates in words. Originally built for Jekyll.
License: MIT License
⌛ Ruby library to compute distance of dates in words. Originally built for Jekyll.
License: MIT License
Setting depth
decides the number of fields that will show up. A different way might be to set granularity, which decides the most specific time period that will be picked. For eg:
granularity: `month`
2 years and 3 months ago
granularity: `year`
2 years ago
granularity: `week`
2 years, 3 months, and 1 week ago
I'm using the plugin at https://endoflife.date
, and several scenarios result in the middle time-interval getting skipped. So I see: 2 years and 3 weeks ago
or 1 year and 4 days ago
. (depth
=2).
It would be much better to have a granularity (say month
), and any results are at most that granular, unless you are forced to do otherwise (26 days ago
or 1 week, 3 days to go
).
With the following liquid filter, {{ site.time | timeago: include.event_date }}
I inevitably get "in 1 year and x months" when the event_date is in the past. Is there any way to reverse the calculation?
Plugin is worked, but jekyll get an invalid date when use filter like this:
<time datetime="{{ post.date | date_to_xmlschema }}">
{{ page.date | timeago }}
</time>
or other use like post.date. but is work when used standard filter {{ site.time | timeago }}
so i think that wrong format my date Front Matter, but it was not. the output page.date is 2019-07-27 19:05:49 +0700
my jekyll version is 3.8.6 and this my _config.yml
timezone: Asia/Jakarta
plugins:
- jekyll-timeago
jekyll_timeago:
depth: 4
translations_path: '/path_to_your_translations/*.yaml'
default_locale: 'en'
fallbacks: true
available_locales:
- 'en'
- 'es'
- 'fr'
this is --trace output:
Liquid Exception: Liquid error (line 8): invalid date in /_layouts/home.html
bundler: failed to load command: jekyll (/home/diaz/gems/bin/jekyll)
Liquid::ArgumentError: Liquid error (line 8): invalid date
/home/diaz/gems/gems/jekyll-timeago-0.13.1/lib/jekyll-timeago/core.rb:36:in `parse'
/home/diaz/gems/gems/jekyll-timeago-0.13.1/lib/jekyll-timeago/core.rb:36:in `validate_date'
/home/diaz/gems/gems/jekyll-timeago-0.13.1/lib/jekyll-timeago/core.rb:25:in `timeago'
/home/diaz/gems/gems/jekyll-timeago-0.13.1/lib/jekyll-timeago/jekyll_integration.rb:37:in `timeago'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/strainer.rb:56:in `invoke'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/context.rb:86:in `invoke'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/variable.rb:84:in `block in render'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in `each'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in `inject'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in `render'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/block_body.rb:80:in `render'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/tags/for.rb:160:in `block (2 levels) in render_segment'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/tags/for.rb:158:in `each'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/tags/for.rb:158:in `block in render_segment'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/context.rb:123:in `stack'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/tags/for.rb:150:in `render_segment'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/tags/for.rb:79:in `render'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/block_body.rb:82:in `render'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
/home/diaz/gems/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:30:in `block (2 levels) in render!'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:42:in `measure_bytes'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:29:in `block in render!'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:49:in `measure_time'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:28:in `render!'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/renderer.rb:126:in `render_liquid'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/renderer.rb:195:in `render_layout'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/renderer.rb:158:in `place_in_layouts'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/renderer.rb:88:in `render_document'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/renderer.rb:62:in `run'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/site.rb:479:in `render_regenerated'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/site.rb:472:in `block in render_pages'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/site.rb:471:in `each'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/site.rb:471:in `render_pages'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/site.rb:192:in `render'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/site.rb:71:in `process'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/command.rb:28:in `process_site'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/commands/build.rb:65:in `build'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/commands/build.rb:36:in `process'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/commands/serve.rb:93:in `block in start'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/commands/serve.rb:93:in `each'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/commands/serve.rb:93:in `start'
/home/diaz/gems/gems/jekyll-3.8.6/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
/home/diaz/gems/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
/home/diaz/gems/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
/home/diaz/gems/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
/home/diaz/gems/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
/home/diaz/gems/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
/home/diaz/gems/gems/jekyll-3.8.6/exe/jekyll:15:in `<top (required)>'
/home/diaz/gems/bin/jekyll:23:in `load'
/home/diaz/gems/bin/jekyll:23:in `<top (required)>'
It works fine on my local system but once I push to remote. It doesn't work
Hello!
Not sure what I am doing wrong but both methods - installing and adding gem and the second method - with putting those 2 plugins inside _plugins dir did not worked.
Jekyll: 2.3.0
gem: 2.2.2
ruby: 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
rbenv 0.4.0-98-g13a474c
OS X 10.10 (Yosemite)
Hello!
I'm using this in a standard site.posts for loop:
{{ post.date | timeago }}
I have a test post that is dated today, yet instead of displaying 'today' I'm just getting 'day'.
Any ideas? My config is as follows:
jekyll_timeago:
depth: 2
today: 'today'
yesterday: 'yesterday'
tomorrow: 'tomorrow'
and: 'and'
suffix: 'ago'
prefix: ''
suffix_future: 'in'
prefix_future: ''
years: 'years'
year: 'year'
months: 'months'
month: 'month'
weeks: 'weeks'
week: 'week'
days: 'days'
day: 'day'
Cheers,
Dave
Thanks for the plugin.
How I could use it in french ?
{{ page.date | localize | timeago }} ?
Thanks
Stop assuming all months have 30 days as it is now :squirrel:
Hey,
I'm getting this exception:
Liquid Exception: Invalid depth level: nil in about.md
My about.md
looks like this:
---
---
{% timeago 2000-1-1 %}
I very unfamiliar with ruby, but after some playing with filter.rb
, it seems that options
are not set because setup
wasn't called.
I'm using Jekyll 3.0.3 and Ruby 2.2.4p240.
Hi
Awesome Plugin 👍
how about adding feature sec, min, hour?
something like this:
30 second ago
35 minutes ago
6 hours ago
Good afternoon.
I have problems to switch locales from English to French. I tried everything but couldn't manage to switch them. I added the locale: fr
property into the front matter, I added the default_local: fr
property in my _config.yml, and finally I downloaded the fr.yml file from the repository. I wonder if it is a problem of installation.
Thanks for your help! :)
Hello, good morning
If you can help me
I have the following occurrence
As images we see that in the local environment runs the plugin "Jekyll-Timeago"
But in the NET feature does not work
I did what your documentation suggests and just copied timeago.rb
into _plugins
. This is the output:
/usr/local/Cellar/ruby/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- jekyll/timeago/version (LoadError)
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Volumes/ssd2/code/xdsd/_plugins/timeago.rb:1:in `<top (required)>'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/lib/jekyll/site.rb:77:in `block (2 levels) in setup'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/lib/jekyll/site.rb:76:in `each'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/lib/jekyll/site.rb:76:in `block in setup'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/lib/jekyll/site.rb:75:in `each'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/lib/jekyll/site.rb:75:in `setup'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/lib/jekyll/site.rb:29:in `initialize'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/lib/jekyll/commands/build.rb:5:in `new'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/lib/jekyll/commands/build.rb:5:in `process'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-1.5.1/bin/jekyll:97:in `block (2 levels) in <top (required)>'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/command.rb:180:in `call'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/command.rb:180:in `call'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/command.rb:155:in `run'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/runner.rb:422:in `run_active_command'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/runner.rb:66:in `run!'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/delegates.rb:8:in `run!'
from /usr/local/Cellar/ruby/2.1.0/lib/ruby/gems/2.1.0/gems/commander-4.1.6/lib/commander/import.rb:10:in `block in <top (required)>'
Suppose 1 | Expected value | Calculation formula? |
---|---|---|
1 week 3 days. | 10 days ago. | |
1 week 4 days. | 2 weeks ago. | |
1 month and 2 weeks. | 6 weeks ago | |
1 month and 3 weeks. | 2 months ago |
_config.yml
jekyll_timeago:
depth: 1
threshold: 0.05
translations_path: "data/timeago_zh_hans.yaml"
default_locale: 'zh_hans'
available_locales:
- 'en'
- 'zh_hans'
thanks!!
this is due ruby 3?
.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/jekyll-timeago-0.15.0/lib/jekyll-timeago/core.rb:36:in
parse': invalid date (Date::Error)
`
Fixed and created pull request.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.