Skip to content

Instantly share code, notes, and snippets.

@elvio
Created July 15, 2013 10:34
Show Gist options
  • Save elvio/5999040 to your computer and use it in GitHub Desktop.
Save elvio/5999040 to your computer and use it in GitHub Desktop.
Original
------------------------------------------------------------
9 + <% t = first.starts_at %>
10 + <% if t.today? %>
11 + <%= I18n.t("landing.today") %>
12 + <% elsif t.tomorrow? %>
13 + <%= I18n.t("landing.tomorrow") %>
14 + <% else %>
15 + <%= I18n.l t, :format => :short %>
16 + <% end %>
Suggestion
------------------------------------------------------------
def human_date(date)
if date.today?
I18n.t("landing.today")
elsif date.tomorrow?
I18n.t("landing.tomorrow")
else
I18n.l t, :format => :short
end
end
<span class="bc-time"><%= human_date(first.starts_at) %></span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment