[ create a new paste ] login | about

Link: http://codepad.org/IZ0YDnJF    [ raw code | output | fork ]

Ruby, pasted on Mar 5:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Time
  def method_missing(name,*args)
    if name.to_s =~ /f_/
      c = args[0] || ' '
      x = name.to_s[2..-1].split(//).
          map {|f| f =~ /[a-z]/i ? "%"+f : c}.
          join
      strftime(x)
    else
      super
    end
  end
end

puts  Time.now.f_Yj           #=> "2008065" 
puts  Time.now.f_s            #=> "1204725800" 
puts  Time.now.f_d_m_Y        #=> "05 03 2008" 
puts  Time.now.f_d_m_Y('-')   #=> "05-03-2008" 
puts  Time.now.f_d_b_Y        #=> "05 Mar 2008"


Output:
1
2
3
4
5
6
2008065
1204732226
05 03 2008
05-03-2008
05 Mar 2008



Create a new paste based on this one


Comments: