Class: Peanuts::Converter::Convert_datetime
- Inherits:
-
Convert_string
- Object
- Peanuts::Converter
- Convert_string
- Peanuts::Converter::Convert_datetime
- Defined in:
- lib/peanuts/converters.rb
Overview
An XSD datetime.
- Specifier
-
:datetime
- Ruby type
-
Time
Options
Accepts all options of Convert_string
.
Instance Method Summary collapse
- #from_xml(string) ⇒ Object
-
#initialize(options) ⇒ Convert_datetime
constructor
A new instance of Convert_datetime.
- #to_xml(time) ⇒ Object
Methods inherited from Peanuts::Converter
create, create!, lookup, lookup!
Constructor Details
#initialize(options) ⇒ Convert_datetime
Returns a new instance of Convert_datetime.
196 197 198 199 |
# File 'lib/peanuts/converters.rb', line 196 def initialize() super @fraction_digits = [:fraction_digits] || 0 end |
Instance Method Details
#from_xml(string) ⇒ Object
205 206 207 |
# File 'lib/peanuts/converters.rb', line 205 def from_xml(string) (string = super(string)) && Time.parse(string) end |
#to_xml(time) ⇒ Object
201 202 203 |
# File 'lib/peanuts/converters.rb', line 201 def to_xml(time) super(time && time.xmlschema(@fraction_digits)) end |