Carlos G encountered problematic C++ code and investigated its history.
The original code parsed expiry dates assuming a "YYMM" format.
It used sscanf with a format string "%2d%2d" to extract year and month.
However, the actual input format was discovered to be "MMYY".
A flawed fix involved manually rearranging the input string characters to "YYMM" before parsing.
This intermediate fix was justified by a misleading comment and a misplaced blame.
The developer believed the input format was altered elsewhere, leading to the complex rearrangement.
Carlos G then provided a clean solution by correcting the sscanf format string.
The new code correctly assumes an "MMYY" input format.
It directly parses the input into month and year variables without unnecessary string manipulation.
thedailywtf.com
thedailywtf.com
