Class: Time

Inherits:
Object
  • Object
show all
Extended by:
TimeParse
Defined in:
lib/vendor/twitter/lib/twitter/ext/stdlib.rb

Overview

Extension to Time that outputs RFC2822 compliant string on #to_s

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



3
4
5
# File 'lib/cerberus/publisher/twitter.rb', line 3

def Time.parse(args)
  Date.parse(args)
end

Instance Method Details

#old_to_sObject



23
# File 'lib/vendor/twitter/lib/twitter/ext/stdlib.rb', line 23

alias :old_to_s :to_s

#to_s(format = nil) ⇒ Object

Returns RFC2822 compliant string for Time object. For example,

# Tony Blair's last day in office (hopefully)
best_day_ever = Time.local(2007, 6, 27)
best_day_ever.to_s # => "Wed, 27 Jun 2007 00:00:00 +0100"

You can also pass in an option format argument that corresponds to acceptable values according to ActiveSupport’s Time#to_formatted_s method.



33
34
35
# File 'lib/vendor/twitter/lib/twitter/ext/stdlib.rb', line 33

def to_s(format = nil)
  format ? self.to_formatted_s(format) : self.rfc2822
end