Module: Jekyll::Timeago::Core
Constant Summary collapse
- DAYS_PER =
{ :days => 1, :weeks => 7, :months => 30, :years => 365 }
- MAX_DEPTH_LEVEL =
Max level of detail years > months > weeks > days 1 year and 7 months and 2 weeks and 6 days
4
- DEFAULT_DEPTH_LEVEL =
Default level of detail 1 month and 5 days, 3 weeks and 2 days, 2 years and 6 months
2
Instance Method Summary collapse
Instance Method Details
#configure(options = {}) ⇒ Object
40 41 42 |
# File 'lib/jekyll-timeago/core.rb', line 40 def configure( = {}) @defaults = defaults.merge() end |
#timeago(from, to = Date.today, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jekyll-timeago/core.rb', line 24 def timeago(from, to = Date.today, = {}) if to.is_a?(Hash) = to to = Date.today end @defaults = defaults unless defined?(@defaults) @options = @defaults.merge() from = validate_date!(from) to = validate_date!(to) depth = validate_depth!(@options["depth"]) time_ago_to_now(from, to, depth) end |