Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.46 KB | None | 0 0
  1. module TimeFormatter
  2.   include MyFormats
  3.  
  4.   refine String do
  5.     def format_to_my_name
  6.       self.gsub(MY_NAME_FORMAT,"")
  7.     end
  8.   end
  9.  
  10.   refine Time do
  11.     def format_to_my_datetime(timezone)
  12.       self.getlocal(timezone).strftime(MY_DATETIME_FORMAT)
  13.     end
  14.   end
  15.  
  16.   refine ActiveSupport::TimeWithZone do
  17.     def method_missing(method, *args)
  18.       if Time.respond_to?(method)
  19.          self.to_time.send(:method, *args)
  20.       end
  21.     end
  22.   end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement