Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/brdata/time_portuguese.rb

Instance Method Summary collapse

Instance Method Details

#strftime(format) ⇒ Object

Formata a hora usando nomes de dias e meses em Portugues Exemplo: hora = Time.new hora.strftime(“%B”) ==> “Janeiro” forum.rubyonbr.org/forums/1/topics/261



35
36
37
38
39
40
41
42
# File 'lib/brdata/time_portuguese.rb', line 35

def strftime(format)
  format = format.dup
  format.gsub!(/%a/, Date::ABBR_DAYNAMES[self.wday])
  format.gsub!(/%A/, Date::DAYNAMES[self.wday])
  format.gsub!(/%b/, Date::ABBR_MONTHNAMES[self.mon])
  format.gsub!(/%B/, Date::MONTHNAMES[self.mon])
  self.strftime_nolocale(format)
end

#strftime_nolocaleObject



19
# File 'lib/brdata/time_portuguese.rb', line 19

alias :strftime_nolocale :strftime

#to_s_brObject

Retorna a hora no padrao brasileiro

Exemplo:

hora = Time.new
hora.to_s_br ==> "27/09/2007 13:54"


26
27
28
# File 'lib/brdata/time_portuguese.rb', line 26

def to_s_br
  self.strftime("%d/%m/%Y %H:%M")
end