ConvertDateFormatMultiple failures on osx

Description

10:35:49.506 775 [192.168.253.50:0{1}] Assert (0011-01-31 = 11-01-31) failed [ConvertDateFormatMultiple('1/31/11', ['%d %b %Y', '%Y %b %d', '%Y%m%d', '%Y-%m-%d', '%d/%m/%Y', '%m/%d/%Y'], '%Y-%m-%d') = '11-01-31']
10:35:49.506 775 ERROR: 100000 - Assert (0011-01-31 = 11-01-31) failed [ConvertDateFormatMultiple('1/31/11', ['%d %b %Y', '%Y %b %d', '%Y%m%d', '%Y-%m-%d', '%d/%m/%Y', '%m/%d/%Y'], '%Y-%m-%d') = '11-01-31']
10:35:49.506 775 [192.168.253.50:0{1}] Assert (0011-01-31 = 11-01-31) failed [ConvertDateFormatMultiple('1/31/11', ['%d %b %Y', '%Y %b %d', '%Y%m%d', '%Y-%m-%d', '%d/%m/%Y', '%m/%d/%Y'], '%Y-%m-%d') = '11-01-31']
10:35:49.506 775 ERROR: 100000 - Assert (0011-01-31 = 11-01-31) failed [ConvertDateFormatMultiple('1/31/11', ['%d %b %Y', '%Y %b %d', '%Y%m%d', '%Y-%m-%d', '%d/%m/%Y', '%m/%d/%Y'], '%Y-%m-%d') = '11-01-31']

Conclusion

None

Activity

Show:

Dan Camper June 17, 2019 at 2:32 PM

Question: It would be far simpler to pad the year to four digits for non-macOS systems than to remove leading zeroes for any %Y output format on macOS systems. This would change the behavior of %Y for *nix systems, which is the majority of our installations. Would that be an acceptable change, providing it goes into 7.4.0 and is called out as a RedBook item?

Gavin Halliday June 17, 2019 at 2:18 PM

Assign to Dan for the moment

Dan Camper June 14, 2019 at 1:02 PM

I read the original error report backwards. I originally thought that when using the '%Y' formatter macOS was not emitting 0011 as the year when it was supposed to, but it actually emits 0011 when it is not supposed to (according to the unit tests).

FWIW, on macOS:

macOS does not use glibc, so the forced formatting does not work.

Dan Camper June 13, 2019 at 7:00 PM

Also, note that it is actually Std.Date.DateToString() that is dropping the leading zeroes:

Dan Camper June 13, 2019 at 6:28 PM

The result of calling:

Results in '11-01-31' on Ubuntu 18.04 as well, with my 7.2.x branch.

Documentation for strftime does not require that %Y output four digits, only that it includes the century.

One workaround is to request a four-digit year in the return format:

That is a glibc extension, however. I'm not sure if is universally applicable.

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

Details

Components

Assignee

Reporter

Priority

Compatibility

Minor

Fix versions

Pull Request URL

Affects versions

Created June 13, 2019 at 9:37 AM
Updated June 27, 2019 at 9:07 AM
Resolved June 27, 2019 at 9:07 AM