Solved TD-22922: [All TD versions] SalXMLDeserializeDateTime conversion incorrect

Report TD 5.x and 6.x bugs and possible workarounds.
Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Posts: 3384
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

TD-22922: [All TD versions] SalXMLDeserializeDateTime conversion incorrect

Post by Dave Rabelink » 07 Mar 2017, 13:17

Since TD 5.1 we have this function __SalXMLDeserializeDateTime (from SalXMLws.apl) which is used to convert a XML DateTime string to TD DateTime value in webservices.

In all TD versions, the TD implementation is incorrect. Including the latest TD 6.3.

First a list of possible XML DateTime example values:

A) "2016-11-28T23:59:49"
B) "2016-11-28T23:59:49Z"
C) "2016-11-28T23:59:49-06:00"
D) "2016-11-28T23:59:49+06:00"

In all cases, the datetime in TD should be:

2016-11-28 23:59:49

Right now, only B) and D) are correctly converted.
Examples A) and C) will result in:

2016-11-27 22.58.59

Looking at the implementation, the cause is clear.

The line

Set sXMLParsed = '1900-01-01-' || sXMLParsed

should be done AFTER the checks for Z, + and - and not before.
Right now, the '1900-01-01-' part of the string will be used to check if it contains a - sign. This is always the case and it results in an invalid datetime.

Even the corrected functionality is incorrect as it just strips Z, + and - signs from the DateTime. There is a reason why these characters are there.
When TD converts the XML value it should REALLY convert to the timezone and daysavings of the system it is running on.

See sample (saved in TD51 format). Select the XML value in the combo and execute. See the datetime result in the field.
You do not have the required permissions to view the files attached to this post.
Dave Rabelink

Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Igor Ivanovic
Site Admin
Site Admin
Posts: 1462
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: TD-22922: [All TD versions] SalXMLDeserializeDateTime conversion incorrect

Post by Igor Ivanovic » 09 Mar 2017, 09:21

Just tried it on TD7.0 UPD1 and it is working.
All the dates are the same.

Igor Ivanovic

Return to “Bug Reports”

Who is online

Users browsing this forum: [Ccbot] and 2 guests