Class: RubyRest::Atom::DateProperty
Class Method Summary
collapse
Instance Method Summary
collapse
#app, #bind, #format, #initialize, #object_value, #parse, #tag, #xml_value
Class Method Details
160
161
162
163
164
|
# File 'lib/rubyrest/atom.rb', line 160
def self.format_date( date )
date = Time.now if !date
date = Time.at( date ) if date.is_a?( Bignum )
date.strftime( ATOM_DATE_FORMAT )
end
|
Instance Method Details
#date2string(date) ⇒ Object
166
167
168
|
# File 'lib/rubyrest/atom.rb', line 166
def date2string( date )
self.class.format_date( date )
end
|
#string2date(str) ⇒ Object
170
171
172
173
|
# File 'lib/rubyrest/atom.rb', line 170
def string2date( str )
date = Date.strptime( str, ATOM_DATE_FORMAT )
Time.gm( date.year, date.month, date.day, 0, 0, 0, 0 ).to_i
end
|
#value_from_model(options, object) ⇒ Object
175
176
177
|
# File 'lib/rubyrest/atom.rb', line 175
def value_from_model( options, object )
date2string( object_value( object, options ) )
end
|
#value_from_xml(options, xml) ⇒ Object
179
180
181
|
# File 'lib/rubyrest/atom.rb', line 179
def value_from_xml( options, xml )
string2date( xml_value( xml, options ) )
end
|