Yesterday, a computer program I wrote more than ten years ago ran into a snag. I won’t go into detail, but what tripped it up is the fact that two consecutive dates, when written as YYYYMMDD, accidentally formed a third date.
January 20, 2012, was written as 20120120.
January 21 became 20120121.
Joined together, they formed 2012012020120121, which, as you see, contained the string for February 1.
That messed up my program.
I could fix the program in two minutes, but I’d have to spend two days getting approval and filling out forms in order to change a program that’s been in production for years. And it’s not worth it if this is a once-in-a-lifetime occurrence.
So I need to figure out when, if ever, the juxtaposition of two dates in YYYYMMDD format will accidentally form a future date. The two dates don’t have to be consecutive, but they do have to be in order, and the third date has to follow both of them; and all three dates should fall within a twelve-month window.
If it’s not going to happen again for another twenty years, I’ll rest easy. I doubt the program will still be in use then, and even if it is, I’ll be retired.
I’m looking for either the next pair of dates that fit the criteria, or an algorithm for finding them. Any suggestions, other than brute force (i.e., actually checking every possible pair of dates between now and 2032)?