Recommended Way To Handle Non-ISO Date Formats

Posted by Kaex on
URL: https://discuss.orbeon.com/Recommended-Way-To-Handle-Non-ISO-Date-Formats-tp4410775.html

Hi all,

Unfortunately, I've run into an issue while trying to send my form instance to a third party service provider.  They insist on not taking ISO formatted (yyyy-mm-dd) dates, but instead expect dates to be in US format (mm/dd/yyyy).  :(

What is the recommended approach for handling this in Orbeon?  So far I have the following binds that *almost* work:

<xforms:bind id="applicant-dob-bind" nodeset="instance('iso-dates')/dob"
                  type="xforms:date"
                  constraint="if(. != '')
                  then
                      (xs:date(.) le current-date())
                  else
                      true()"  
                 
                  xxforms:default="if (string-length(instance('fr-form-instance')/dob) gt 0)
                  then
                     (xs:date(.....Nasty substring code to change to ISO format.....))  
                  else
                      xxforms:get-request-attribute('applicantDob', 'text/plain')"/>

<xforms:bind nodeset="PersonalDetails/DateOfBirth"
                  calculate="format-date(instance('non-iso-dates')/dob, '[M01]/[D01]/[Y]')" />