4

App uses SOAP4r for consuming API/SOAP

But SOAP::SOAPTimeFormat is returning 2015-11-15T16:59:521468.7999999999999545-04:00

chkout.add('purchasedDt ', SOAP::SOAPDateTime.new(basket.purchase_Date))

Using strftime('%Y-%m-%dT%H:%M:%S') is giving the following

chkout.add('purchasedDt ', SOAP::SOAPDateTime.new(basket.purchase_Date.strftime('%Y-%m-%dT%H:%M:%S')))

2015-11-15T16:59:52Z

What App needs is
2015-11-15 16:59:52 -0400 Please advise ...need the format in yyyy-mm-ddThh:mm:ss-/+gmt

-Fransis

Fransis
  • 275
  • 1
  • 5
  • 15

2 Answers2

2

A simple change in your strftime and you can find out more in the doc for Time#strftime

basket.purchase_Date.now.strftime('%Y-%m-%d %H:%M %z')
=> "2016-04-26 22:48 -0400"
Thomas R. Koll
  • 3,131
  • 1
  • 19
  • 26
2

Seems like your applicaton accepts the iso8601 format. You can use Time#xmlschema as a shortcut to generate iso8601 compatible strings:

basket.purchase_Date.xmlschema
#=> "2015-11-15T16:59:52-04:00"

Just change this line in your example:

chkout.add('purchasedDt ', SOAP::SOAPDateTime.new(basket.purchase_Date.xmlschema))
spickermann
  • 100,941
  • 9
  • 101
  • 131
  • 1
    From the [docs](http://ruby-doc.org/stdlib-2.3.1/libdoc/time/rdoc/Time.html#method-i-xmlschema): *If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.* It seems like your timestamp is already UTC. Can you please call `.zone` on your timestamp? That returns the timezone of the timestamp. I would like to understand the conflict between the behavior and the `-04:00` part in your post. – spickermann Apr 28 '16 at 15:33
  • I used SOAPString and .zone ..it shows "Eastern Daylight Time" in the SoapUI. **chkout.add('purchasedDt',SOAP::SOAPString.new(referral.created_at.zone))** – Fransis Apr 28 '16 at 17:20