The ball had just dropped, and Eric was taking the stairs to the fifteenth floor two at a time. Initech's New Year's party was in full swing, but it Eric wasn't simply in a hurry to join the festivities. He'd been watching the support queue all night, and at midnight the new monitoring program lit up like Times Square. The program was supposed to be simple: The new security cameras Initech had installed in their headquarters dumped video files in a folder every hour, and the powers-that-be wanted to make sure they were working without being obliged to keep an obssessive eye on the filesystem. Eric's colleague Ted was put in charge of solving the problem before the party, and he'd dumped his solution onto a production server in the nick of time. All had been well... for the first hour.
Eric burst through the balcony doors, out of breath. Around him, fellow Initechnicians were pouring champagne and trying to remember the inscrutable lyrics to Auld Lang Syne. Ted had attached himself to a gaggle of salespeople in sharp blue suits, one of whom was handing around cigars. Before Ted could lay hands on a lighter, Eric clasped his shoulder.
"Ted," he panted, "something's wrong with your monitor."
"What? I turned it off before I came upstairs..."
"Not your display, the service you wrote to confirm that camera footage is getting saved."
"Oh," Ted said, eyes straying to his stogie. "Guess I'll... look into it on Tuesday?"
"No good. Mr. Petersen's already seen the failure email, and he isn't happy. We'd better get to the bottom of this before he cancels our contract with the camera company."
"Uh, well, the party's just getting started up here! Would you do me a solid and take a look?"
Eric narrowed his eyes, and muscled Ted towards the doors. "You didn't even check your code into source control, buddy. Time for a little pair programming."
Once Ted's workstation had warmed back up, it didn't take long to find the problem. Since the files were simply named with the format
YYYYMMDDHH.avi, Ted had figured out what filename was sought like this:
string fileName = videoPath + "\" + utcNow.Year + utcNow.Month.ToString("00") + utcNow.Day.ToString("00") + (utcNow.Hour - 1).ToString("00") + "." + ConfigurationManager.AppSettings["VideosExtension"];
Ted was squinting at the code through a bit of a haze, so Eric pointed it out to him:
Hour property returns an int between zero and twenty-three. So midnight minus one is going to give you... minus one."
"Oh," Ted said. "I've got this. We'll be back at the party in no time."
He thought carefully for a minute, and then typed this:
string fileName = videoPath + "\" + utcNow.Year + utcNow.Month.ToString("00") + utcNow.Day.ToString("00") + (utcNow.AddHours(-1).Hour).ToString("00") + "." + ConfigurationManager.AppSettings["VideosExtension"];
Ted was about to commit his changes to production when Eric pushed him gently away from the keyboard.
"Close," he said, plucking the Macanudo from Ted's shirt pocket and putting it in his own. "But no cigar."