NineOnions and PurpleCarrots

|

The search for nonsense.

Posts Tagged ‘MapForce’

Unexpected Behavior

Sunday, February 1st, 2009

“0929″ != 929.

This is the premise of a recent bug that I needed to bash. I’m processing a flat file wherein a time is specified in “HHmm” format. The mapping calls for the two left characters to be interpreted as the hour and the two right characters to be interpreted as the minute. This works great for times such as “2204″ or “1039″, but was failing miserably for some reason. The exception that was raised stated the DateTime was not in the correct format. I looked into the mapping file and saw a proper time “0929″ equivalent to 9:29 AM. In debugging, however, the hour being passed to the DateTime constructor was 92. This was the obvious source of the error.
Looking back at the mapping file, I learned that the mapping software we are using transparently converts the “0929″ string into the number 929 before passing it along the pipe. Converted back into a string for the LEFT(2) and RIGHT(2) gave a nonsense time of 92:29. This type of we-hid-the-details-from-you bugs are absolutely irritating. The workaround was relatively simple, just adding a few more controls into the mapping, but it shouldn’t have been necessary. The datum was a string value and had no sense being converted to an integer before actually being turned into a DateTime value.