Module: Jekyll::Timeago::Core
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- STYLES =
Available styles
%w(default short array)- ONLY_OPTIONS =
Available “only” options
%w(years months weeks days)
Instance Method Summary collapse
Instance Method Details
#timeago(from, to = Date.today, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jekyll-timeago/core.rb', line 23 def timeago(from, to = Date.today, = {}) if to.is_a?(Hash) = to to = Date.today end = @from = validate_date(from) @to = validate_date(to) @depth = validate_depth([:depth] || ["depth"]) @style = validate_style([:style] || ["style"]) @threshold = validate_threshold([:threshold] || ["threshold"]) @only = validate_only([:only] || ["only"]) time_ago_to_now end |