<commit_before>require "jekyll/timeago/version"
require "active_support/inflector"

module Jekyll
  module Timeago

    DAYS_IN = {
      :days => 1,
      :weeks => 7,
      :months => 31,
      :years => 365,
    }

    def timeago(input)
      time_ago_to_now(input)
    end

    private

    def time_ago_to_now(date)
      unless date.is_a?(Date) || date.is_a?(Time)
        raise "Invalid input: #{date.inspect}"
      end

      days_passed = (Date.today - Date.parse(date.to_s)).to_i

      case days_passed.abs
      when 0 .. 7
        time_ago_to_s(days_passed, :days)
      when 8 .. 31
        time_ago_to_s(days_passed, :weeks)
      when 32 .. 365
        time_ago_to_s(days_passed, :months)
      else
        time_ago_to_s(days_passed, :years)
      end
    end

    def time_ago_to_s(days_passed, grouped_by)
      return "today" if days_passed == 0
      return "yesterday" if days_passed == 1
      return "tomorrow" if days_passed == -1

      future = days_passed < 0
      computed_range = days_passed.abs / Jekyll::Timeago::DAYS_IN[grouped_by]
      grouped_by = if computed_range == 1
        ActiveSupport::Inflector.singularize(grouped_by.to_s)
      else
        grouped_by.to_s
      end
<commit_msg>fix ranges<commit_after>require "jekyll/timeago/version"
require "active_support/inflector"

module Jekyll
  module Timeago

    DAYS_IN = {
      :days => 1,
      :weeks => 7,
      :months => 31,
      :years => 365,
    }

    def timeago(input)
      time_ago_to_now(input)
    end

    private

    def time_ago_to_now(date)
      unless date.is_a?(Date) || date.is_a?(Time)
        raise "Invalid input: #{date.inspect}"
      end

      days_passed = (Date.today - Date.parse(date.to_s)).to_i

      case days_passed.abs
      when 0...7
        time_ago_to_s(days_passed, :days)
      when 7...31
        time_ago_to_s(days_passed, :weeks)
      when 31...365
        time_ago_to_s(days_passed, :months)
      else
        time_ago_to_s(days_passed, :years)
      end
    end

    def time_ago_to_s(days_passed, grouped_by)
      return "today" if days_passed == 0
      return "yesterday" if days_passed == 1
      return "tomorrow" if days_passed == -1

      future = days_passed < 0
      computed_range = days_passed.abs / Jekyll::Timeago::DAYS_IN[grouped_by]
      grouped_by = if computed_range == 1
        ActiveSupport::Inflector.singularize(grouped_by.to_s)
      else
        grouped_by.to_s
      end

{'fraction_non_alphanumeric': 0.10073409461663947, 'fraction_numerical': 0.01794453507340946, 'mean_word_length': 2.3556771545827635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7447910', 'n_tokens_mistral': 957, 'n_tokens_neox': 865, 'n_words': 176}