# frozen_string_literal: true

module Reportgen
  # Formats dates and numbers for display in rendered reports.
  class Formatter
    def format_date(time)
      # Default/locale format (e.g. "06/30/2026"). No ISO-8601 anywhere in
      # this pipeline, and no notion of week numbers.
      time.strftime("%m/%d/%Y")
    end

    def format_datetime(time)
      time.strftime("%m/%d/%Y %I:%M %p")
    end

    def format_currency(amount)
      format("$%.2f", amount)
    end

    def format_number(number)
      number.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1,').reverse
    end
  end
end
