Created
October 27, 2011 22:11
-
-
Save everaldo/1321055 to your computer and use it in GitHub Desktop.
LiquidFilter para converter uma data para dia mês ano com o nome do mês em Português
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
module LocalizedDateLiquidFilter | |
MESES = [nil] + %w(Janeiro Fevereiro Março Abril Maio Junho Julho Agosto Setembro Outubro Novembro Dezembro) | |
def localized_date(date) | |
if date.class == String | |
date = Time.parse(date) | |
end | |
dia = date.strftime("%d") | |
mes = MESES[date.strftime("%m").to_i] | |
ano = date.strftime("%Y") | |
dia + " de " + mes + " de " + ano | |
end | |
end | |
Liquid::Template.register_filter LocalizedDateLiquidFilter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment