Class: Peanuts::Converter::Convert_datetime

Inherits:
Convert_string show all
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

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(options)
  super
  @fraction_digits = options[: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