defmodule MarcCx.PageView do
  use MarcCx.Web, :view
end

defmodule MarcCx.PageView do
  use MarcCx.Web, :view
  use Timex
  alias MarcCx.Article

  def format_date(%Article{:timestamp => timestamp}) do
    {:ok, date} = DateFormat.parse("#{timestamp}", "{s-epoch}")

    [month, day, year] =
      date
      |> DateFormat.format!("%B %d %Y", :strftime)
      |> String.split(" ")

    day = day |> String.lstrip(?0)

    day = case String.last(day) do
      "1" -> "#{day}st"
      "2" -> "#{day}nd"
      "3" -> "#{day}rd"
      _   -> "#{day}th"
    end

    "#{month} #{day} #{year}"
  end
end

Add a format_date function to the PageView for formatting published dates from Articles
Add a format_date function to the PageView for formatting published dates from Articles

marcaddeo/marc.cx,marcaddeo/marc.cx,marcaddeo/marc.cx