Date Conversion library no longer cleaning multiple formats

Description

The following code only cleans the first date format:

dateFullYr := '06/04/2018';
date2DgtYr := '06/04/18';

fmtsin := [
'%m/%d/%Y',
'%m/%d/%y'
];
fmtout:='%Y%m%d';

OUTPUT(dateFullYr,NAMED('dateFullYr'));
OUTPUT(date2DgtYr,NAMED('date2DgtYr'));
OUTPUT(Std.date.ConvertDateFormatMultiple(dateFullYr,fmtsin,fmtout),NAMED('CleanedDateFullYr'));
OUTPUT(Std.date.ConvertDateFormatMultiple(date2DgtYr,fmtsin,fmtout),NAMED('CleanedDate2DgtYr'));

WU on Prod: W20180605-100640-2

'06/04/18' returns as blank.

This worked using 6.2.24: W20180528-165002 (Prod)

Reversing the order of the fmtsin will incorrectly clean '06/04/2018': W20180605-100954 (Prod)

 

Conclusion

None

Activity

Show:

Dan Camper June 12, 2018 at 12:05 PM

correctly pointed out that changing the behavior of %Y would cause years < 1000 to not be parsed correctly, which forced me to do some more digging.  It turns out that the fix applied for  was the cause of the behavior change cited in this issue.  The fix for both this issue and the prior one involves solving the prior issue with a different method.

Dan Camper June 6, 2018 at 12:54 PM

I found the problem exhibited by the example code: readValue() within stringlib claims success when it reads any number of digits less than the maximum. For the case where the input is a two-digit year but the format string wants a four digit year, readValue() will "successfully" parse the two digit year and then an invalid time structure is eventually created. This code was last touched in 2011, so I'm somewhat mystified as to how it worked in a version 6.x.x platform.

As to the problem where reversing the list of possible formats to try, there is not an easy way to avoid that problem. The best solution here probably lies in documentation: Recommend to the caller that any formats containing %Y should appear before formats containing %y, as %y results can encompass %Y results.

Please assign to me.

Richard Chapman June 6, 2018 at 9:19 AM

Any ideas?

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Components

Assignee

Reporter

Priority

Compatibility

Major

Fix versions

Labels

Affects versions

Created June 5, 2018 at 2:11 PM
Updated September 6, 2018 at 11:17 AM
Resolved September 6, 2018 at 11:17 AM