Module: StringToDatetimeForSoap

Defined in:
lib/action_web_service/string_to_datetime_for_soap.rb

Instance Method Summary collapse

Instance Method Details

#to_datetimeObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/action_web_service/string_to_datetime_for_soap.rb', line 3

def to_datetime
  begin
    if /^([+\-]?\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ self.strip
      return Time.xmlschema(self).localtime
    end
    super
  rescue
    # If a invalid date is supplied, it will automatically turn it into the first Julian Day
    # Jan/01 - 4712 BC - This is a simple solution, until a better one appear :)
    return Date.new
  end
end