Module: Jekyll::Timeago::Core

Extended by:
Core
Included in:
Core
Defined in:
lib/jekyll-timeago/core.rb

Constant Summary collapse

MAX_DEPTH_LEVEL =

Max level of detail: years > months > weeks > days

4
DEFAULT_DEPTH_LEVEL =

Default level of detail

2
DEFAULT_THRESHOLD =

Default threshold

0

Instance Method Summary collapse

Instance Method Details

#timeago(from, to = Date.today, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jekyll-timeago/core.rb', line 17

def timeago(from, to = Date.today, options = {})
  if to.is_a?(Hash)
    options = to
    to = Date.today
  end

  @options = options

  from      = validate_date(from)
  to        = validate_date(to)
  depth     = validate_depth(@options[:depth] || @options["depth"])
  threshold = validate_threshold(@options[:threshold])

  time_ago_to_now(from, to, depth, threshold)
end