<commit_before>module TimeHelper

  # Our goal here it to automatically display the date in the way that
  # makes the most sense. Elusive, i know. If an array of times is passed in
  # we display the newest one.
  # Here are the current options:
  #   4:30PM    -- time was today
  #   Wednesday -- time was within the last week.
  #   7/Mar     -- time was in the current year.
  #   7/Mar/08  -- time was in a different year.
  # The date is then wrapped in a label, so that if you hover over the text
  # you will see the full details.
  def friendly_date(*times)
    return "" unless times.any?

    time  = times.compact.max
    today = Time.zone.today
    date  = time.to_date

    if date == today
      # 4:30PM
      str = time.strftime("%I:%M<span>%p</span>")
    elsif today > date and (today-date) < 7
      # I18n.t(:wednesday) => Wednesday
      str = I18n.t(time.strftime("%A").downcase.to_sym)
    elsif date.year != today.year
      # 7/Mar/08
      str = date.strftime('%d') + '/' + localize_month(date.strftime('%B')) + '/' + date.strftime('%y')
    else
      # 7/Mar
      str = date.strftime('%d') + '/' + localize_month(date.strftime('%B'))
    end
    "<label class='date' title='#{ full_time(time) }'>#{str}</label>"
  end

  def localize_month(month)<commit_msg>friendly date now uses wday instead of strfdate for translation keys<commit_after>module TimeHelper

  # Our goal here it to automatically display the date in the way that
  # makes the most sense. Elusive, i know. If an array of times is passed in
  # we display the newest one.
  # Here are the current options:
  #   4:30PM    -- time was today
  #   Wednesday -- time was within the last week.
  #   7/Mar     -- time was in the current year.
  #   7/Mar/08  -- time was in a different year.
  # The date is then wrapped in a label, so that if you hover over the text
  # you will see the full details.


  WeekdaySymbols = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday]

  def friendly_date(*times)
    return "" unless times.any?

    time  = times.compact.max
    today = Time.zone.today
    date  = time.to_date

    if date == today
      # 4:30PM
      str = time.strftime("%I:%M<span>%p</span>")
    elsif today > date and (today-date) < 7
      # I18n.t(:wednesday) => Wednesday
      str = I18n.t(WeekdaySymbols[time.wday])
    elsif date.year != today.year
      # 7/Mar/08
      str = date.strftime('%d') + '/' + localize_month(date.strftime('%B')) + '/' + date.strftime('%y')
    else
      # 7/Mar
      str = date.strftime('%d') + '/' + localize_month(date.strftime('%B'))
    end
    "<label class='date' title='#{ full_time(time) }'>#{str}</label>"
  end

  def localize_month(month)
{'fraction_non_alphanumeric': 0.13360323886639677, 'fraction_numerical': 0.013986013986013986, 'mean_word_length': 2.687924016282225, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '7217436', 'n_tokens_mistral': 951, 'n_tokens_neox': 908, 'n_words': 289}